A
abir
Hi,
i need to work on a certain types of sequences which has a specific
property.
some of the properties i can deduce based on a few typenames, but
others i can't
eg i want to know a class which supports insert.
so i have
template<typename T> struct can_insert : public std::false_type{};
and explicitly write
template<typename T> struct can_insert<std::vector<T>> : public
std::true_type{}; etc
for my own classes i can introduce a tag for the whole category
instead of specializing for each one
eg
template<typename T,typename Enabler = void> struct can_insert :
public std::false_type{};
and
template<typename T>
struct can_insert < enable_if<typename T::insert_tag>::type> struct
can_insert : public std::true_type{};
where for my class i define the tag
struct mytype{
typedef std::true_type insert_tag ;
}
but i can't have a tag for all of the classes. so i am looking for
something like
template<typename T>
struct can_insert<T, enable_if<has_member<T,T::*insert>::type > :
public std::true_type{};
so can i detect if a member (function or variable) of some specific
signature is present in the class?
(something like __if_exists in MSVC ? )
thanks
abir
i need to work on a certain types of sequences which has a specific
property.
some of the properties i can deduce based on a few typenames, but
others i can't
eg i want to know a class which supports insert.
so i have
template<typename T> struct can_insert : public std::false_type{};
and explicitly write
template<typename T> struct can_insert<std::vector<T>> : public
std::true_type{}; etc
for my own classes i can introduce a tag for the whole category
instead of specializing for each one
eg
template<typename T,typename Enabler = void> struct can_insert :
public std::false_type{};
and
template<typename T>
struct can_insert < enable_if<typename T::insert_tag>::type> struct
can_insert : public std::true_type{};
where for my class i define the tag
struct mytype{
typedef std::true_type insert_tag ;
}
but i can't have a tag for all of the classes. so i am looking for
something like
template<typename T>
struct can_insert<T, enable_if<has_member<T,T::*insert>::type > :
public std::true_type{};
so can i detect if a member (function or variable) of some specific
signature is present in the class?
(something like __if_exists in MSVC ? )
thanks
abir