Which templates (if any) in the C++ standard library have one or more template template parameters?
If there are many, then a couple of examples is fine.
If C++ version matters, then the latest draft of C++14/C++1y is preffered.
I'm not aware of any templates in the C++ standard library that are specified to take a template template parameter, but there is at least one standard template in C++11 that has a partial specialization with a template template parameter: std::pointer_traits
. std::pointer_traits<Ptr>::element_type
is specified to be:
Ptr::element_type
if such a type exists; otherwise,T
ifPtr
is a class template instantiation of the formSomePointer<T, Args>
, whereArgs
is zero or more type arguments; otherwise, the specialization is ill-formed.
In order to implement this you need a template template parameter for SomePointer
, because it can be an arbitrary class template (as long as it only has type template parameters, to be precise). Here is the libstdc++ helper class partial specialization that does this, for instance:
template<template<typename, typename...> class _SomePtr, typename _Tp,
typename... _Args>
struct __ptrtr_elt_type<_SomePtr<_Tp, _Args...>, false>
{
typedef _Tp __type;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With