Boost logo

Boost :

Subject: Re: [boost] [type_traits]common_type and SFINAE
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-10-08 12:19:33

On Mon, Oct 8, 2012 at 6:44 AM, Louis Dionne <louis.dionne92_at_[hidden]> wrote:
> Lorenzo Caminiti <lorcaminiti <at>> writes:
>> Hello all,
>> common_type<T, U>::type is defined in a way that gives a hard compiler
>> error if T and U do not have a common type (this is also how
>> common_type is implemented in C++11).
>> An alternative design (I'm not sure if implementable) would have been
>> to not define the type member in case T and U have no common type.
>> This way I could use SFINAE to detect if common_type<T, U>::type does
>> not exist and therefore if T and U have not common type -- so to
>> implement N3351's concept Common<T, U>.
>> Is there a way to implement this alternative design?
> While this is not directly linked to your question, I have implemented some
> concepts using SFINAE so you can write stuff like:
> template <typename T>
> typename std::enable_if<LessThanComparable<T>::value>::type func() { }
> What I did works only in C++11. You may take a look at what I did here:
> I'll be glad if this can be of any help. Please do not hesitate to contact me
> for anything.

Thanks. FYI, this is definitely relevant to the email thread "[boost]
[contract] toward N3351 concepts" and probably to the one about
Boost.Generic as well.


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