Revert "Revert "Merge to upstream r304942.""
This reverts commit 38a0d5af7e.
Test: make checkbuild
Test: ./run_tests.py
Test: ./run_tests.py --bitness 64
This commit is contained in:
@@ -416,7 +416,7 @@ void throws_in_constructor_test()
|
||||
ThrowsOnCopy() = default;
|
||||
bool operator()() const {
|
||||
assert(false);
|
||||
#if defined(_LIBCPP_MSVC)
|
||||
#if defined(TEST_COMPILER_C1XX)
|
||||
__assume(0);
|
||||
#else
|
||||
__builtin_unreachable();
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
|
||||
// class function<R(ArgTypes...)>
|
||||
|
||||
// function(const function& f);
|
||||
// function(const function& f);
|
||||
// function(const function&& f);
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
@@ -63,6 +63,7 @@ int main()
|
||||
assert(A::count == 1);
|
||||
assert(f.target<A>());
|
||||
assert(f.target<int(*)(int)>() == 0);
|
||||
assert(f.target<int>() == nullptr);
|
||||
}
|
||||
assert(A::count == 0);
|
||||
{
|
||||
@@ -70,6 +71,7 @@ int main()
|
||||
assert(A::count == 0);
|
||||
assert(f.target<int(*)(int)>());
|
||||
assert(f.target<A>() == 0);
|
||||
assert(f.target<int>() == nullptr);
|
||||
}
|
||||
assert(A::count == 0);
|
||||
{
|
||||
@@ -77,6 +79,7 @@ int main()
|
||||
assert(A::count == 1);
|
||||
assert(f.target<A>());
|
||||
assert(f.target<int(*)(int)>() == 0);
|
||||
assert(f.target<int>() == nullptr);
|
||||
}
|
||||
assert(A::count == 0);
|
||||
{
|
||||
@@ -84,6 +87,7 @@ int main()
|
||||
assert(A::count == 0);
|
||||
assert(f.target<int(*)(int)>());
|
||||
assert(f.target<A>() == 0);
|
||||
assert(f.target<int>() == nullptr);
|
||||
}
|
||||
assert(A::count == 0);
|
||||
}
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// reference_wrapper
|
||||
|
||||
// check for deriving from binary_function
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
class functor1
|
||||
: public std::unary_function<int, char>
|
||||
{
|
||||
};
|
||||
|
||||
class functor2
|
||||
: public std::binary_function<char, int, double>
|
||||
{
|
||||
};
|
||||
|
||||
class functor3
|
||||
: public std::unary_function<int, int>,
|
||||
public std::binary_function<char, int, double>
|
||||
{
|
||||
public:
|
||||
typedef float result_type;
|
||||
};
|
||||
|
||||
class functor4
|
||||
: public std::unary_function<int, int>,
|
||||
public std::binary_function<char, int, double>
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
typedef int argument_type;
|
||||
typedef int result_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((!std::is_base_of<std::binary_function<int, char, int>,
|
||||
std::reference_wrapper<functor1> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<char, int, double>,
|
||||
std::reference_wrapper<functor2> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<char, int, double>,
|
||||
std::reference_wrapper<functor3> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<char, int, double>,
|
||||
std::reference_wrapper<functor4> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<int, int, int>,
|
||||
std::reference_wrapper<C> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float ()> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float (int)> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float (int, int)> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float(*)()> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float(*)(int)> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<int, int, float>,
|
||||
std::reference_wrapper<float(*)(int, int)> >::value), "");
|
||||
static_assert((!std::is_base_of<std::binary_function<C*, int, float>,
|
||||
std::reference_wrapper<float(C::*)()> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<C*, int, float>,
|
||||
std::reference_wrapper<float(C::*)(int)> >::value), "");
|
||||
static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>,
|
||||
std::reference_wrapper<float(C::*)(int) const volatile> >::value), "");
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// <functional>
|
||||
|
||||
// reference_wrapper
|
||||
|
||||
// check for deriving from unary_function
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
class functor1
|
||||
: public std::unary_function<int, char>
|
||||
{
|
||||
};
|
||||
|
||||
class functor2
|
||||
: public std::binary_function<char, int, double>
|
||||
{
|
||||
};
|
||||
|
||||
class functor3
|
||||
: public std::unary_function<int, int>,
|
||||
public std::binary_function<char, int, double>
|
||||
{
|
||||
public:
|
||||
typedef float result_type;
|
||||
};
|
||||
|
||||
class functor4
|
||||
: public std::unary_function<int, int>,
|
||||
public std::binary_function<char, int, double>
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
struct C
|
||||
{
|
||||
typedef int argument_type;
|
||||
typedef int result_type;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::unary_function<int, char>,
|
||||
std::reference_wrapper<functor1> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<char, int>,
|
||||
std::reference_wrapper<functor2> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<int, int>,
|
||||
std::reference_wrapper<functor3> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<int, int>,
|
||||
std::reference_wrapper<functor4> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<int, int>,
|
||||
std::reference_wrapper<C> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<int, float>,
|
||||
std::reference_wrapper<float(*)()> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<int, float>,
|
||||
std::reference_wrapper<float (int)> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<int, float>,
|
||||
std::reference_wrapper<float (int, int)> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<int, float>,
|
||||
std::reference_wrapper<float(*)(int)> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<int, float>,
|
||||
std::reference_wrapper<float(*)(int, int)> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<C*, float>,
|
||||
std::reference_wrapper<float(C::*)()> >::value), "");
|
||||
static_assert((std::is_base_of<std::unary_function<const volatile C*, float>,
|
||||
std::reference_wrapper<float(C::*)() const volatile> >::value), "");
|
||||
static_assert((!std::is_base_of<std::unary_function<C*, float>,
|
||||
std::reference_wrapper<float(C::*)(int)> >::value), "");
|
||||
}
|
||||
@@ -36,6 +36,7 @@ test()
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
typedef typename std::underlying_type<T>::type under_type;
|
||||
|
||||
H h1;
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
@@ -31,6 +33,7 @@ test()
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
H h;
|
||||
|
||||
std::size_t t0 = h(0.);
|
||||
|
||||
@@ -31,6 +31,7 @@ test()
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
H h;
|
||||
|
||||
for (int i = 0; i <= 5; ++i)
|
||||
@@ -64,42 +65,42 @@ int main()
|
||||
test<long long>();
|
||||
test<unsigned long long>();
|
||||
|
||||
// LWG #2119
|
||||
// LWG #2119
|
||||
test<std::ptrdiff_t>();
|
||||
test<size_t>();
|
||||
|
||||
test<int8_t>();
|
||||
test<int16_t>();
|
||||
test<int32_t>();
|
||||
test<int64_t>();
|
||||
test<int8_t>();
|
||||
test<int16_t>();
|
||||
test<int32_t>();
|
||||
test<int64_t>();
|
||||
|
||||
test<int_fast8_t>();
|
||||
test<int_fast16_t>();
|
||||
test<int_fast32_t>();
|
||||
test<int_fast64_t>();
|
||||
test<int_fast8_t>();
|
||||
test<int_fast16_t>();
|
||||
test<int_fast32_t>();
|
||||
test<int_fast64_t>();
|
||||
|
||||
test<int_least8_t>();
|
||||
test<int_least16_t>();
|
||||
test<int_least32_t>();
|
||||
test<int_least64_t>();
|
||||
test<int_least8_t>();
|
||||
test<int_least16_t>();
|
||||
test<int_least32_t>();
|
||||
test<int_least64_t>();
|
||||
|
||||
test<intmax_t>();
|
||||
test<intptr_t>();
|
||||
|
||||
test<uint8_t>();
|
||||
test<uint16_t>();
|
||||
test<uint32_t>();
|
||||
test<uint64_t>();
|
||||
test<uint8_t>();
|
||||
test<uint16_t>();
|
||||
test<uint32_t>();
|
||||
test<uint64_t>();
|
||||
|
||||
test<uint_fast8_t>();
|
||||
test<uint_fast16_t>();
|
||||
test<uint_fast32_t>();
|
||||
test<uint_fast64_t>();
|
||||
test<uint_fast8_t>();
|
||||
test<uint_fast16_t>();
|
||||
test<uint_fast32_t>();
|
||||
test<uint_fast64_t>();
|
||||
|
||||
test<uint_least8_t>();
|
||||
test<uint_least16_t>();
|
||||
test<uint_least32_t>();
|
||||
test<uint_least64_t>();
|
||||
test<uint_least8_t>();
|
||||
test<uint_least16_t>();
|
||||
test<uint_least32_t>();
|
||||
test<uint_least64_t>();
|
||||
|
||||
test<uintmax_t>();
|
||||
test<uintptr_t>();
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
|
||||
#include "test_macros.h"
|
||||
|
||||
template <class T>
|
||||
void
|
||||
test()
|
||||
@@ -30,6 +32,7 @@ test()
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
H h;
|
||||
|
||||
typedef typename std::remove_pointer<T>::type type;
|
||||
@@ -38,7 +41,20 @@ test()
|
||||
assert(h(&i) != h(&j));
|
||||
}
|
||||
|
||||
// can't hash nullptr_t until c++17
|
||||
void test_nullptr()
|
||||
{
|
||||
#if TEST_STD_VER > 14
|
||||
typedef std::nullptr_t T;
|
||||
typedef std::hash<T> H;
|
||||
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
|
||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||
ASSERT_NOEXCEPT(H()(T()));
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int*>();
|
||||
test_nullptr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user