Re: generally prefer references in range-based for loops

2018-10-29 Thread Walt Karas
https://github.com/apache/trafficserver/blob/master/proxy/logging/LogObject.cc#L1008 We also have cases of the opposite problem, using a reference for a container of pointers / iterators / string_views or other small objects. But this is less serious and probably just an aesthetic issue (gets opt

some troubled with executing autest 1.7.0

2018-10-29 Thread 毛建峰
Hello All I am very interested in ATS, but we have some troubled with executing autest. When we executed autest 1.7.0 in ATS 7.1.5 some case often failed. Total of 42 test Unknown: 0 Exception: 0 Failed: 25 Warning: 0 Skipped: 3 Passed: 14 Most of case failed with: file /home/a

Re: generally prefer references in range-based for loops

2018-10-29 Thread Pushkar Pradhan
Good catch. In Modern Effective C++ Scott Myers talks about a few scenarios when auto doesn't do what the programmer intended. Earlier I was inclined to suggest that we should avoid auto in ATS but I think it's better to make mistakes and learn. On Fri, Oct 26, 2018 at 3:21 PM Walt Karas wrote:

Re: some troubled with executing autest 1.7.0

2018-10-29 Thread Jason Kenny
Hi, from the logs I think you want to look at the _sandbox directory to see if the files there show anything. What is odd is that you are failing on returns codes such as 52 and 35. This might be a sign of something else. - Jason On Mon, Oct 29, 2018 at 12:21 PM 毛建峰 wrote: > add the logs file

Re: generally prefer references in range-based for loops

2018-10-29 Thread Alan Carroll
I tend to use `for ( auto && x : container)`. That seems to work well and gives the compiler more flexibility. I recommend it unless there's a specific reason to not do so. Testing with a std::vector and a function that takes (int) it does the correct thing - it passes the int values directly to th

Re: generally prefer references in range-based for loops

2018-10-29 Thread Walt Karas
I'm not convinced: https://godbolt.org/z/M8pZl0 On Mon, Oct 29, 2018 at 1:48 PM Alan Carroll wrote: > > I tend to use `for ( auto && x : container)`. That seems to work well and > gives the compiler more flexibility. I recommend it unless there's a > specific reason to not do so. Testing with a

Re: generally prefer references in range-based for loops

2018-10-29 Thread Pushkar Pradhan
It seems like auto isn't that "auto". You still need to be familiar with all the gotchas. On Mon, Oct 29, 2018 at 11:48 AM Alan Carroll wrote: > I tend to use `for ( auto && x : container)`. That seems to work well and > gives the compiler more flexibility. I recommend it unless there's a > spe

Re: generally prefer references in range-based for loops

2018-10-29 Thread Walt Karas
Yes and no. I think Alan is correct in the sense that if you use for (auto &&r : , and it compiles OK, the object code is going to be correct and optimal. I just have my aesthetic opinion that it can make the code slightly harder to maintain. On Mon, Oct 29, 2018 at 6:47 PM Pushkar Pradhan wrote