Reputation:
template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};
It appears in the possible implementation of std::experimental::make_array
. The reason it looks odd to me is that the class name contains a template parameter list <std::reference_wrapper<T>>
mentioning only one parameter, but that parameter is inside the template argument of the class (i.e. something has been elided).
Upvotes: 1
Views: 63
Reputation: 63154
That lines goes in tandem with the one above it:
template<class> struct is_ref_wrapper : std::false_type {};
template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};
The first line declares the (primary) template is_ref_wrapper
. The second line declares a specialization, which will be chosen instead of the primary template if and only if the parameter matches std::reference_wrapper<T>
for some T
. Which is exactly the required behaviour.
Upvotes: 2
Reputation: 206737
The other related line from the page you linked to is:
template<class> struct is_ref_wrapper : std::false_type {};
This defines the generic template. The next line is a specialization.
template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};
When is_ref_wrapper
is instantiated with a std::reference_wrapper<T>
as the template parameter, the specialization is used.
Upvotes: 2