зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1168008 - Make IsConvertible handle void. r=gerald
This commit is contained in:
Родитель
b4c9a784ca
Коммит
868aa56b18
|
@ -637,12 +637,31 @@ public:
|
|||
* 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
|
||||
* 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>
|
||||
struct IsConvertible
|
||||
: 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.1 Const-volatile modifications [meta.trans.cv] */
|
||||
|
|
|
@ -354,6 +354,10 @@ TestIsConvertible()
|
|||
static_assert((!IsConvertible<A, D>::value),
|
||||
"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
|
||||
// for now just disable them.
|
||||
//static_assert((!IsConvertible<C*, A*>::value),
|
||||
|
|
Загрузка…
Ссылка в новой задаче