mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1153295 - Add mozilla::Declval. r=nfroyd
This commit is contained in:
parent
fba7e2edc1
commit
00a33b3cfd
@ -811,6 +811,17 @@ struct AddRvalueReference
|
||||
: detail::AddRvalueReferenceHelper<T>
|
||||
{};
|
||||
|
||||
/* 20.2.4 Function template declval [declval] */
|
||||
|
||||
/**
|
||||
* DeclVal simplifies the definition of expressions which occur as unevaluated
|
||||
* operands. It converts T to a reference type, making it possible to use in
|
||||
* decltype expressions even if T does not have a default constructor, e.g.:
|
||||
* decltype(DeclVal<TWithNoDefaultConstructor>().foo())
|
||||
*/
|
||||
template<typename T>
|
||||
typename AddRvalueReference<T>::Type DeclVal();
|
||||
|
||||
/* 20.9.7.3 Sign modifications [meta.trans.sign] */
|
||||
|
||||
template<bool B, typename T = void>
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
using mozilla::AddLvalueReference;
|
||||
using mozilla::AddRvalueReference;
|
||||
using mozilla::DeclVal;
|
||||
using mozilla::IsArray;
|
||||
using mozilla::IsBaseOf;
|
||||
using mozilla::IsClass;
|
||||
@ -385,6 +386,23 @@ static_assert(IsSame<AddRvalueReference<void>::Type, void>::value,
|
||||
static_assert(IsSame<AddRvalueReference<struct S1&>::Type, struct S1&>::value,
|
||||
"not reference-collapsing struct S1& && to struct S1& correctly");
|
||||
|
||||
struct TestWithDefaultConstructor
|
||||
{
|
||||
int foo() const { return 0; }
|
||||
};
|
||||
struct TestWithNoDefaultConstructor
|
||||
{
|
||||
explicit TestWithNoDefaultConstructor(int) {}
|
||||
int foo() const { return 1; }
|
||||
};
|
||||
|
||||
static_assert(IsSame<decltype(TestWithDefaultConstructor().foo()), int>::value,
|
||||
"decltype should work using a struct with a default constructor");
|
||||
static_assert(IsSame<decltype(DeclVal<TestWithDefaultConstructor>().foo()), int>::value,
|
||||
"decltype should work using a DeclVal'd struct with a default constructor");
|
||||
static_assert(IsSame<decltype(DeclVal<TestWithNoDefaultConstructor>().foo()), int>::value,
|
||||
"decltype should work using a DeclVal'd struct without a default constructor");
|
||||
|
||||
static_assert(IsSame<MakeSigned<const unsigned char>::Type, const signed char>::value,
|
||||
"const unsigned char won't signify correctly");
|
||||
static_assert(IsSame<MakeSigned<volatile unsigned short>::Type, volatile signed short>::value,
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "mozilla/Likely.h"
|
||||
#include "mozilla/MacroArgs.h"
|
||||
#include "mozilla/MacroForEach.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
namespace mozilla {
|
||||
template <typename T>
|
||||
@ -62,9 +63,7 @@ struct HasDangerousPublicDestructor
|
||||
namespace mozilla {
|
||||
struct IsDestructibleFallbackImpl
|
||||
{
|
||||
template<typename T> static T&& Declval();
|
||||
|
||||
template<typename T, typename = decltype(Declval<T>().~T())>
|
||||
template<typename T, typename = decltype(DeclVal<T>().~T())>
|
||||
static TrueType Test(int);
|
||||
|
||||
template<typename>
|
||||
|
Loading…
Reference in New Issue
Block a user