Boost logo

Boost :

Subject: Re: [boost] "Simple C++11 metaprogramming"
From: Peter Dimov (lists_at_[hidden])
Date: 2015-06-05 08:42:16


Eric Niebler wrote:
> > (This implements the specification in the latest C++17 draft.)
>
> I'm not so sure. If a user defines a specialization for common_type<MyInt,
> int>, it won't get used when computing
common_type<MyInt, int, int>.

As it turns out, users are not allowed to specialize common_type, which is
why the C++17 specification does not concern itself with such
specializations.

As a curiosity, decaying the arguments before the conditional operator is
also subtly wrong.

#include <iostream>
#include <typeinfo>

struct X
{
    operator int ();
    operator long () const;
};

struct Y
{
    operator int ();
    operator long () const;
};

int main()
{
    std::cout << typeid( true? declval<X const&>(): declval<Y
const&>() ).name() << std::endl;
    std::cout << typeid( true? declval<X&>(): declval<Y&>() ).name() <<
std::endl;
    std::cout << typeid( true? declval<X>(): declval<Y>() ).name() <<
std::endl;
}


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