|
Boost : |
Subject: Re: [boost] [type_traits] templated type traits?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2012-11-09 19:11:27
AMDG
On 11/09/2012 03:45 PM, Lorenzo Caminiti wrote:
> Is there a way to inspect if a type is a template instantiaton
> (is_templated) and the type of the instantiated template parameters
> (arg1_type)?
>
> is_templated< std::vector<int> >::value // true
> is_templated< int >::value // false
>
> template_traits< std::vector<int> >::arg1_type // int
>
If you don't have any non-type template
parameters or template template parameters,
it's easy:
template<class T>
struct is_template : boost::mpl::false_ {};
template<template<class...> class T, class... U>
struct is_template<T<U...> > : boost::mpl::true_ {};
template<class T>
struct template_traits;
template<template<class...> class T, class... U>
struct template_traits {
typedef typename boost::mpl::vector<U...> arg_types;
};
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk