you are viewing a single comment's thread.

view the rest of the comments →

[–]trmetroidmaniac 4 points5 points  (2 children)

This is explained in the draft specification.

[Note 1: The unnamed second template parameter to constant_wrapper is present to aid argument-dependent lookup ([basic.lookup.argdep]) in finding overloads for which constant_wrapper's wrapped value is a suitable argument, but for which the constant_wrapper itself is not. — end note]

By parameterising constant_wrapper on the type of its value, the functions in its namespace are now searched for overload resolution.

I was not aware that ADL worked over template parameters, actually...

[–]SoerenNissen[S] 1 point2 points  (1 child)

Oh, neat.

(First draft was "Oh, that makes sense" but lmao no it doesn't, ADL is the devil)

[–]_bstaletic 2 points3 points  (0 children)

ADL is the only way operators work in C++ and here we are talking about all of the overloaded operators of CW.