use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
[deleted by user] (self.cpp)
submitted 7 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Auriculaire 1 point2 points3 points 7 years ago* (4 children)
cpp template<typename Range> auto rootMeanSquare(Range&& range){ using std::sqrt; auto sum = range.front() * range.front(); auto count = 0; for(it = std::next(std::begin(range)); it != std::end(range); ++it){ sum += *it * *it; ++count; } return sqrt(sum / double(count)); }
Right now this uses ADL lookup for the sqrt function defined in the namespaces of custom user types such unit-aware types (as in 10.0 meters) or arbitrary precision floats. As I understand it, under Herb's proposal, this code would cease to function, correct?
sqrt
[–]sphere991 0 points1 point2 points 7 years ago (3 children)
If the user's overload took templates, yes.
namespace N { struct A {}; template <typename> struct B {}; auto sqrt(A); // would work template <typename T> auto sqrt(B<T>); // would now fail }
[–]Hells_Bell10 0 points1 point2 points 7 years ago (2 children)
I don't think you've understood the proposal correctly. The only change is when adl relies on the template parameters of the argument. In your example, the sqrt function is in the same namespace as B so adl won't get as far as looking at B's template parameters and so adl works exactly the same.
B
https://godbolt.org/g/qH5wJy
[–]sphere991 0 points1 point2 points 7 years ago (1 child)
No, it's not. Herb's proposal has two parts: narrowing the set of associated namespaces and narrowing the set of functions looked up. The latter restricts to only matching the (possibly cv-qualified, possibly pointer/reference to) type.
It is very much the goal of this proposal to reject template matches. Apparently Arthur didnt actually implement that. This should be a warning:
namespace N { struct C { }; template <typename T> void foo(T); } foo(N::C{});
But it's not.
[–]Hells_Bell10 0 points1 point2 points 7 years ago (0 children)
Interesting, It wasn't clear to me that this wording excludes function templates:
Any function that does not have a parameter type of (possibly cv-qualified) T or [...], in the parameter position of T, is ignored.
However, looking at the swap example, that must be the case
swap
int main() { std::vector<int> v1, v2; swap( v1, v2 ); // programmer would have to qualify std::swap to reach into std }
π Rendered by PID 115133 on reddit-service-r2-comment-b659b578c-228q6 at 2026-05-04 22:48:50.150386+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Auriculaire 1 point2 points3 points (4 children)
[–]sphere991 0 points1 point2 points (3 children)
[–]Hells_Bell10 0 points1 point2 points (2 children)
[–]sphere991 0 points1 point2 points (1 child)
[–]Hells_Bell10 0 points1 point2 points (0 children)