Boost logo

Boost :

Subject: Re: [boost] [type_traits] Big changes in develop
From: John Maddock (jz.maddock_at_[hidden])
Date: 2015-05-30 03:31:15


On 29/05/2015 21:18, Peter Dimov wrote:

>> And while you're on a roll.... can you see how to fix
>> https://svn.boost.org/trac/boost/ticket/7544? common_type should have
>> member ::type only when such a common type exists.
>
> On C++11 or on C++03?
>
> On C++11, it's as easy as
>
> template<class...> struct common_type
> {
> };
>
> template<class T> struct common_type: decay<T>
> {
> };
>
> template<class T1, class T2, class... T,
> class R = decltype(declval<bool>()? declval<T1>(): declval<T2>())>
>
> struct common_type<T1, T2, T...>: common_type<typename decay<R>::type,
> T...>
> {
> };
>
> On C++03... I don't know, is there a point? It needs expression SFINAE
> and default template parameters for function templates and will
> probably not compile on most non-C++11 compilers anyway. Might be
> useful in principle on clang/gcc in C++03 mode, but is this an
> important target?
>
Probably not, I suspect C++11 only support is fine. The above is really
neat BTW, I tried something similar in VC++ and couldn't get it to work :(

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk