[Bug c++/42013] cv-qualification of conditional expression type depending on the value of its first expression?!?
paolo dot carlini at oracle dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 12 04:09:00 GMT 2009
------- Comment #1 from paolo dot carlini at oracle dot com 2009-11-12 04:09 -------
Actually, the observation about C++0x is largely incorrect, because the actual
specifications in DR 1255 are different, use std::add_rvalue_reference.
However, my main puzzlement stands.
Also, as regards the C++0x common_type (per DR 1255), I'm seeing the problem
with cv-qualified void, eg, replace in the snippet int -> void and const int ->
const void, because in that case std::add_rvalue_reference does nothing:
#include <type_traits>
template<typename _Tp>
struct __declval_protector
{
static typename std::add_rvalue_reference<_Tp>::type __delegate();
};
template<typename _Tp>
typename std::add_rvalue_reference<_Tp>::type
declval()
{
return __declval_protector<_Tp>::__delegate();
}
template<typename _Tp, typename _Up>
struct common_type
{
typedef __decltype(true ? declval<_Tp>() : declval<_Up>()) typet;
typedef __decltype(false ? declval<_Tp>() : declval<_Up>()) typef;
};
template<typename, typename> struct is_same;
template<typename _Tp> struct is_same<_Tp, _Tp> { typedef _Tp type; };
void f()
{
typedef common_type<void, const void>::typet typet;
typedef common_type<void, const void>::typef typef;
typedef is_same<typet, typef>::type type;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42013
More information about the Gcc-bugs
mailing list