Bug 1168008 - Make IsConvertible handle void. r=gerald

This commit is contained in:
Bobby Holley 2015-05-27 21:22:21 -07:00
Родитель b4c9a784ca
Коммит 868aa56b18
2 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -637,12 +637,31 @@ public:
* For obscure reasons, you can't use IsConvertible when the types being tested * For obscure reasons, you can't use IsConvertible when the types being tested
* are related through private inheritance, and you'll get a compile error if * are related through private inheritance, and you'll get a compile error if
* you try. Just don't do it! * you try. Just don't do it!
*
* Note - we need special handling for void, which ConvertibleTester doesn't
* handle. The void handling here doesn't handle const/volatile void correctly,
* which could be easily fixed if the need arises.
*/ */
template<typename From, typename To> template<typename From, typename To>
struct IsConvertible struct IsConvertible
: IntegralConstant<bool, detail::ConvertibleTester<From, To>::value> : IntegralConstant<bool, detail::ConvertibleTester<From, To>::value>
{}; {};
template<typename B>
struct IsConvertible<void, B>
: IntegralConstant<bool, IsVoid<B>::value>
{};
template<typename A>
struct IsConvertible<A, void>
: IntegralConstant<bool, IsVoid<A>::value>
{};
template<>
struct IsConvertible<void, void>
: TrueType
{};
/* 20.9.7 Transformations between types [meta.trans] */ /* 20.9.7 Transformations between types [meta.trans] */
/* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */ /* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */

Просмотреть файл

@ -354,6 +354,10 @@ TestIsConvertible()
static_assert((!IsConvertible<A, D>::value), static_assert((!IsConvertible<A, D>::value),
"A and D are unrelated"); "A and D are unrelated");
static_assert(IsConvertible<void, void>::value, "void is void");
static_assert(!IsConvertible<A, void>::value, "A shouldn't convert to void");
static_assert(!IsConvertible<void, B>::value, "void shouldn't convert to B");
// These cases seem to require C++11 support to properly implement them, so // These cases seem to require C++11 support to properly implement them, so
// for now just disable them. // for now just disable them.
//static_assert((!IsConvertible<C*, A*>::value), //static_assert((!IsConvertible<C*, A*>::value),