How ref qualifiers led to deducing this

5 comments · 95% upvoted · source · other discussions

comments

shahms

You can't = delete a specific overload with deducing this, but you can apply constraints to accomplish something similar.

__christo4us

Member functions that make use of deducing this are actually templates so you can =delete a specific template specialization: ``` struct foo { void f(this auto &&self) { /* ... / } // exactly the same as template<typename T> void f(this T &&self) { / ... */ } };

template<> void foo::f(this foo &&self) = delete; template<> void foo::f(this const foo &&self) = delete; ```

meetingcpp [OP]

Right...

_lerp

This feature is great and I use it, but not did it get messy if you do much more than a getter. Having to spam forward<Self> everywhere gets ugly quick and makes me question if I should just do things the old way.

meetingcpp [OP]

I can see that, you got to deal with lifting things into the generic space. Plus that supporting older standards isn't possible. Which ref qualifiers allow for.