atomgalaxy / isocpp-universal-template-param

We propose a way to spell a universal template parameter kind. This would allow for a generic apply and other higher-order template metafunctions, and certain typetraits.
https://atomgalaxy.github.io/isocpp-universal-template-param/d1985r0.pdf
2 stars 2 forks source link

Added examples for class and variable template overloading. #3

Closed BengtGustafsson closed 4 years ago

BengtGustafsson commented 4 years ago

Tried to correct two other examples to the best of my understanding.

atomgalaxy commented 4 years ago

Maybe just give a signature and a comment then :)

On Sun, May 10, 2020 at 5:05 PM Bengt Gustafsson notifications@github.com wrote:

@BengtGustafsson commented on this pull request.

In d1985r0.md https://github.com/atomgalaxy/isocpp-universal-template-param/pull/3#discussion_r422664854 :

+ + +This example is a metafunction to find a matching element in a tuple +based only on its type. The first overload is usable for a unary predicate like +std::is_reference while the second overload is useful for a binary +predicate like std::is_base_of by using a currying helper. + +Currently this can't be implemented as a variable template which +breaks the symmetry with simpler tuple oriented metafunctions such as +tuple_size_v and tuple_element_t. + +Given an overloaded constexpr function tuple_size we could instead +simplify this to: + +cpp +template