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;
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.