Boost logo

Boost :

Subject: Re: [boost] detecting a constructor with a specific signature
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-01-26 23:48:47

Kenny Riddile wrote:
> I'm trying to create a type trait to detect the presence of a
> constructor with a very specific signature. Types passed to this trait
> will *always* have a constructor of the form:
> T( const std::string& );
> but some of them will have this constructor as well:
> T( const std::string&, Foo& ); // Second parameter will always be a Foo&
> I would like to create a type trait that returns true when the second
> constructor is present. I can't simply do:
> !is_convertible<std::string, T>::value
> since that will return false when the second constructor is present
> since all Ts are convertible from std::string. Is it possible to create
> such a trait?

As Steven Watanabe noted, "AFAIK, it's impossible."

These sound like very specific constructors that you're looking for,
however, so it might be reasonable to use a "flag typedef" within the
class (intrusive) and/or an explicitly specialized metafunction

- Jeff

Boost list run by bdawes at, gregod at, cpdaniel at, john at