diff options
Diffstat (limited to 'test/std/utilities/tuple')
34 files changed, 478 insertions, 178 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp index 2e821945d09a..4c15499f5c1d 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp @@ -166,7 +166,6 @@ void check_apply_quals_and_types(Tuple&& t) { void test_call_quals_and_arg_types() { - TrackedCallable obj; using Tup = std::tuple<int, int const&, unsigned&&>; const int x = 42; unsigned y = 101; @@ -199,7 +198,7 @@ void test_noexcept() // test that the functions noexcept-ness is propagated using Tup = std::tuple<int, const char*, long>; Tup t; - ASSERT_NOEXCEPT(std::apply(nec, t)); + LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, t)); ASSERT_NOT_NOEXCEPT(std::apply(tc, t)); } { @@ -207,7 +206,7 @@ void test_noexcept() using Tup = std::tuple<NothrowMoveable, int>; Tup t; ASSERT_NOT_NOEXCEPT(std::apply(nec, t)); - ASSERT_NOEXCEPT(std::apply(nec, std::move(t))); + LIBCPP_ASSERT_NOEXCEPT(std::apply(nec, std::move(t))); } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp index 143ae195e6f4..eee1dd88253c 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp @@ -175,14 +175,14 @@ void test_noexcept() { Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple<TestType>(ctup)); - ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); } { using Tuple = std::pair<int, NothrowMoveable>; Tuple tup; ((void)tup); Tuple const& ctup = tup; ((void)ctup); ASSERT_NOT_NOEXCEPT(std::make_from_tuple<TestType>(ctup)); - ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(std::move(tup))); } { using Tuple = std::tuple<int, int, int>; @@ -192,7 +192,7 @@ void test_noexcept() { { using Tuple = std::tuple<long, long, long>; Tuple tup; ((void)tup); - ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); } { using Tuple = std::array<int, 3>; @@ -202,7 +202,7 @@ void test_noexcept() { { using Tuple = std::array<long, 3>; Tuple tup; ((void)tup); - ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); + LIBCPP_ASSERT_NOEXCEPT(std::make_from_tuple<TestType>(tup)); } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp index a3d14487b47d..a66fba22d919 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp @@ -23,9 +23,9 @@ int main() { { - typedef std::pair<double, char> T0; - typedef std::tuple<int, short> T1; - T0 t0(2.5, 'a'); + typedef std::pair<long, char> T0; + typedef std::tuple<long long, short> T1; + T0 t0(2, 'a'); T1 t1; t1 = t0; assert(std::get<0>(t1) == 2); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp index 91892efaf139..85dcee893a07 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp @@ -36,26 +36,26 @@ struct D int main() { { - typedef std::tuple<double> T0; - typedef std::tuple<int> T1; - T0 t0(2.5); + typedef std::tuple<long> T0; + typedef std::tuple<long long> T1; + T0 t0(2); T1 t1; t1 = t0; assert(std::get<0>(t1) == 2); } { - typedef std::tuple<double, char> T0; - typedef std::tuple<int, int> T1; - T0 t0(2.5, 'a'); + typedef std::tuple<long, char> T0; + typedef std::tuple<long long, int> T1; + T0 t0(2, 'a'); T1 t1; t1 = t0; assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); } { - typedef std::tuple<double, char, D> T0; - typedef std::tuple<int, int, B> T1; - T0 t0(2.5, 'a', D(3)); + typedef std::tuple<long, char, D> T0; + typedef std::tuple<long long, int, B> T1; + T0 t0(2, 'a', D(3)); T1 t1; t1 = t0; assert(std::get<0>(t1) == 2); @@ -65,10 +65,10 @@ int main() { D d(3); D d2(2); - typedef std::tuple<double, char, D&> T0; - typedef std::tuple<int, int, B&> T1; - T0 t0(2.5, 'a', d2); - T1 t1(1.5, 'b', d); + typedef std::tuple<long, char, D&> T0; + typedef std::tuple<long long, int, B&> T1; + T0 t0(2, 'a', d2); + T1 t1(1, 'b', d); t1 = t0; assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp index afd3e0fdb8e3..1a32acd55cff 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp @@ -39,7 +39,7 @@ struct D struct E { E() = default; - E& operator=(int val) { + E& operator=(int) { return *this; } }; @@ -47,26 +47,26 @@ struct E { int main() { { - typedef std::tuple<double> T0; - typedef std::tuple<int> T1; - T0 t0(2.5); + typedef std::tuple<long> T0; + typedef std::tuple<long long> T1; + T0 t0(2); T1 t1; t1 = std::move(t0); assert(std::get<0>(t1) == 2); } { - typedef std::tuple<double, char> T0; - typedef std::tuple<int, int> T1; - T0 t0(2.5, 'a'); + typedef std::tuple<long, char> T0; + typedef std::tuple<long long, int> T1; + T0 t0(2, 'a'); T1 t1; t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); } { - typedef std::tuple<double, char, D> T0; - typedef std::tuple<int, int, B> T1; - T0 t0(2.5, 'a', D(3)); + typedef std::tuple<long, char, D> T0; + typedef std::tuple<long long, int, B> T1; + T0 t0(2, 'a', D(3)); T1 t1; t1 = std::move(t0); assert(std::get<0>(t1) == 2); @@ -76,19 +76,19 @@ int main() { D d(3); D d2(2); - typedef std::tuple<double, char, D&> T0; - typedef std::tuple<int, int, B&> T1; - T0 t0(2.5, 'a', d2); - T1 t1(1.5, 'b', d); + typedef std::tuple<long, char, D&> T0; + typedef std::tuple<long long, int, B&> T1; + T0 t0(2, 'a', d2); + T1 t1(1, 'b', d); t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); assert(std::get<2>(t1).id_ == 2); } { - typedef std::tuple<double, char, std::unique_ptr<D>> T0; - typedef std::tuple<int, int, std::unique_ptr<B>> T1; - T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3))); + typedef std::tuple<long, char, std::unique_ptr<D>> T0; + typedef std::tuple<long long, int, std::unique_ptr<B>> T1; + T0 t0(2, 'a', std::unique_ptr<D>(new D(3))); T1 t1; t1 = std::move(t0); assert(std::get<0>(t1) == 2); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp index d5d020779726..edb235a41919 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp @@ -16,9 +16,26 @@ // UNSUPPORTED: c++98, c++03 #include <tuple> +#include <memory> #include <string> #include <cassert> +#include "test_macros.h" + +struct NonAssignable { + NonAssignable& operator=(NonAssignable const&) = delete; + NonAssignable& operator=(NonAssignable&&) = delete; +}; +struct CopyAssignable { + CopyAssignable& operator=(CopyAssignable const&) = default; + CopyAssignable& operator=(CopyAssignable &&) = delete; +}; +static_assert(std::is_copy_assignable<CopyAssignable>::value, ""); +struct MoveAssignable { + MoveAssignable& operator=(MoveAssignable const&) = delete; + MoveAssignable& operator=(MoveAssignable&&) = default; +}; + int main() { { @@ -51,4 +68,37 @@ int main() assert(std::get<1>(t) == 'a'); assert(std::get<2>(t) == "some text"); } + { + // test reference assignment. + using T = std::tuple<int&, int&&>; + int x = 42; + int y = 100; + int x2 = -1; + int y2 = 500; + T t(x, std::move(y)); + T t2(x2, std::move(y2)); + t = t2; + assert(std::get<0>(t) == x2); + assert(&std::get<0>(t) == &x); + assert(std::get<1>(t) == y2); + assert(&std::get<1>(t) == &y); + } + { + // test that the implicitly generated copy assignment operator + // is properly deleted + using T = std::tuple<std::unique_ptr<int>>; + static_assert(!std::is_copy_assignable<T>::value, ""); + } + { + using T = std::tuple<int, NonAssignable>; + static_assert(!std::is_copy_assignable<T>::value, ""); + } + { + using T = std::tuple<int, CopyAssignable>; + static_assert(std::is_copy_assignable<T>::value, ""); + } + { + using T = std::tuple<int, MoveAssignable>; + static_assert(!std::is_copy_assignable<T>::value, ""); + } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp index fc5e41ad569d..210f14be318a 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp @@ -21,6 +21,33 @@ #include "MoveOnly.h" +struct NonAssignable { + NonAssignable& operator=(NonAssignable const&) = delete; + NonAssignable& operator=(NonAssignable&&) = delete; +}; +struct CopyAssignable { + CopyAssignable& operator=(CopyAssignable const&) = default; + CopyAssignable& operator=(CopyAssignable&&) = delete; +}; +static_assert(std::is_copy_assignable<CopyAssignable>::value, ""); +struct MoveAssignable { + MoveAssignable& operator=(MoveAssignable const&) = delete; + MoveAssignable& operator=(MoveAssignable&&) = default; +}; + + +struct CountAssign { + static int copied; + static int moved; + static void reset() { copied = moved = 0; } + CountAssign() = default; + CountAssign& operator=(CountAssign const&) { ++copied; return *this; } + CountAssign& operator=(CountAssign&&) { ++moved; return *this; } +}; +int CountAssign::copied = 0; +int CountAssign::moved = 0; + + int main() { { @@ -53,4 +80,46 @@ int main() assert(std::get<1>(t) == 1); assert(std::get<2>(t) == 2); } + { + // test reference assignment. + using T = std::tuple<int&, int&&>; + int x = 42; + int y = 100; + int x2 = -1; + int y2 = 500; + T t(x, std::move(y)); + T t2(x2, std::move(y2)); + t = std::move(t2); + assert(std::get<0>(t) == x2); + assert(&std::get<0>(t) == &x); + assert(std::get<1>(t) == y2); + assert(&std::get<1>(t) == &y); + } + { + // test that the implicitly generated move assignment operator + // is properly deleted + using T = std::tuple<std::unique_ptr<int>>; + static_assert(std::is_move_assignable<T>::value, ""); + static_assert(!std::is_copy_assignable<T>::value, ""); + + } + { + using T = std::tuple<int, NonAssignable>; + static_assert(!std::is_move_assignable<T>::value, ""); + } + { + using T = std::tuple<int, MoveAssignable>; + static_assert(std::is_move_assignable<T>::value, ""); + } + { + // The move should decay to a copy. + CountAssign::reset(); + using T = std::tuple<CountAssign, CopyAssignable>; + static_assert(std::is_move_assignable<T>::value, ""); + T t1; + T t2; + t1 = std::move(t2); + assert(CountAssign::copied == 1); + assert(CountAssign::moved == 0); + } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp index 812e6329bb3e..27656a675982 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp @@ -39,9 +39,9 @@ struct D int main() { { - typedef std::pair<double, std::unique_ptr<D>> T0; - typedef std::tuple<int, std::unique_ptr<B>> T1; - T0 t0(2.5, std::unique_ptr<D>(new D(3))); + typedef std::pair<long, std::unique_ptr<D>> T0; + typedef std::tuple<long long, std::unique_ptr<B>> T1; + T0 t0(2, std::unique_ptr<D>(new D(3))); T1 t1; t1 = std::move(t0); assert(std::get<0>(t1) == 2); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp index ed3cafadbf08..a5b3d4415e38 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR23256_constrain_UTypes_ctor.pass.cpp @@ -91,6 +91,8 @@ int main() { } { std::tuple<A&&> t(std::forward_as_tuple(A{})); + ((void)t); std::tuple<ExplicitA&&> t2(std::forward_as_tuple(ExplicitA{})); + ((void)t2); } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp new file mode 100644 index 000000000000..dd9b832423a6 --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR31384.pass.cpp @@ -0,0 +1,88 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <tuple> + +// template <class TupleLike> tuple(TupleLike&&); // libc++ extension + +// See llvm.org/PR31384 +#include <tuple> +#include <cassert> + +int count = 0; + +struct Explicit { + Explicit() = default; + explicit Explicit(int) {} +}; + +struct Implicit { + Implicit() = default; + Implicit(int) {} +}; + +template<class T> +struct Derived : std::tuple<T> { + using std::tuple<T>::tuple; + template<class U> + operator std::tuple<U>() && { ++count; return {}; } +}; + + +template<class T> +struct ExplicitDerived : std::tuple<T> { + using std::tuple<T>::tuple; + template<class U> + explicit operator std::tuple<U>() && { ++count; return {}; } +}; + +int main() { + { + std::tuple<Explicit> foo = Derived<int>{42}; ((void)foo); + assert(count == 1); + std::tuple<Explicit> bar(Derived<int>{42}); ((void)bar); + assert(count == 2); + } + count = 0; + { + std::tuple<Implicit> foo = Derived<int>{42}; ((void)foo); + assert(count == 1); + std::tuple<Implicit> bar(Derived<int>{42}); ((void)bar); + assert(count == 2); + } + count = 0; + { + static_assert(!std::is_convertible< + ExplicitDerived<int>, std::tuple<Explicit>>::value, ""); + std::tuple<Explicit> bar(ExplicitDerived<int>{42}); ((void)bar); + assert(count == 1); + } + count = 0; + { + // FIXME: Libc++ incorrectly rejects this code. +#ifndef _LIBCPP_VERSION + std::tuple<Implicit> foo = ExplicitDerived<int>{42}; ((void)foo); + static_assert(std::is_convertible< + ExplicitDerived<int>, std::tuple<Implicit>>::value, + "correct STLs accept this"); +#else + static_assert(!std::is_convertible< + ExplicitDerived<int>, std::tuple<Implicit>>::value, + "libc++ incorrectly rejects this"); +#endif + assert(count == 0); + std::tuple<Implicit> bar(ExplicitDerived<int>{42}); ((void)bar); + assert(count == 1); + } + count = 0; + +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp index 6ab303c735be..06284df56642 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp @@ -20,9 +20,11 @@ #include <cassert> #include <type_traits> +#include "test_macros.h" +#include "test_convertible.hpp" #include "MoveOnly.h" -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 struct Empty {}; struct A @@ -123,17 +125,23 @@ int main() // extensions #ifdef _LIBCPP_VERSION { - std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0), - MoveOnly(1)); + using E = MoveOnly; + using Tup = std::tuple<E, E, E>; + // Test that the reduced arity initialization extension is only + // allowed on the explicit constructor. + static_assert(test_convertible<Tup, E, E, E>(), ""); + + Tup t(E(0), E(1)); + static_assert(!test_convertible<Tup, E, E>(), ""); assert(std::get<0>(t) == 0); assert(std::get<1>(t) == 1); assert(std::get<2>(t) == MoveOnly()); - } - { - std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0)); + + Tup t2(E(0)); + static_assert(!test_convertible<Tup, E>(), ""); assert(std::get<0>(t) == 0); - assert(std::get<1>(t) == MoveOnly()); - assert(std::get<2>(t) == MoveOnly()); + assert(std::get<1>(t) == E()); + assert(std::get<2>(t) == E()); } #endif #if TEST_STD_VER > 11 diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp index c5941618180d..1d0c7b49aaaa 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp @@ -27,8 +27,8 @@ int main() { { - typedef std::pair<double, int> T0; - typedef std::tuple<int, double> T1; + typedef std::pair<long, int> T0; + typedef std::tuple<long long, double> T1; T0 t0(2, 3); T1 t1(std::allocator_arg, A1<int>(5), t0); assert(std::get<0>(t1) == 2); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp index 36d9f32879cb..153cd2b3d7ce 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp @@ -37,9 +37,9 @@ struct Implicit { int main() { { - typedef std::tuple<double> T0; - typedef std::tuple<int> T1; - T0 t0(2.5); + typedef std::tuple<long> T0; + typedef std::tuple<long long> T1; + T0 t0(2); T1 t1(std::allocator_arg, A1<int>(), t0); assert(std::get<0>(t1) == 2); } @@ -65,9 +65,9 @@ int main() assert(std::get<1>(t1) == 3); } { - typedef std::tuple<double, int, int> T0; - typedef std::tuple<int, alloc_first, alloc_last> T1; - T0 t0(1.5, 2, 3); + typedef std::tuple<long, int, int> T0; + typedef std::tuple<long long, alloc_first, alloc_last> T1; + T0 t0(1, 2, 3); alloc_first::allocator_constructed = false; alloc_last::allocator_constructed = false; T1 t1(std::allocator_arg, A1<int>(5), t0); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp index 367f19e5d8dd..0da132fcfc26 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp @@ -19,6 +19,7 @@ #include <string> #include <cassert> +#include "test_macros.h" template <class ...> struct never { @@ -81,12 +82,13 @@ int main() { // check that the literal '0' can implicitly initialize a stored pointer. std::tuple<int*> t = 0; + assert(std::get<0>(t) == nullptr); } { std::tuple<int> t(2); assert(std::get<0>(t) == 2); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { constexpr std::tuple<int> t(2); static_assert(std::get<0>(t) == 2, ""); @@ -101,7 +103,7 @@ int main() assert(std::get<0>(t) == 2); assert(std::get<1>(t) == nullptr); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { constexpr std::tuple<int, char*> t(2, nullptr); static_assert(std::get<0>(t) == 2, ""); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp index d6d489fd0ea4..bed161a3dcef 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp @@ -19,23 +19,25 @@ #include <utility> #include <cassert> +#include "test_macros.h" + int main() { { - typedef std::pair<double, char> T0; - typedef std::tuple<int, short> T1; - T0 t0(2.5, 'a'); + typedef std::pair<long, char> T0; + typedef std::tuple<long long, short> T1; + T0 t0(2, 'a'); T1 t1 = t0; assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == short('a')); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { - typedef std::pair<double, char> P0; - typedef std::tuple<int, short> T1; - constexpr P0 p0(2.5, 'a'); + typedef std::pair<long, char> P0; + typedef std::tuple<long long, short> T1; + constexpr P0 p0(2, 'a'); constexpr T1 t1 = p0; - static_assert(std::get<0>(t1) != std::get<0>(p0), ""); + static_assert(std::get<0>(t1) == std::get<0>(p0), ""); static_assert(std::get<1>(t1) == std::get<1>(p0), ""); static_assert(std::get<0>(t1) == 2, ""); static_assert(std::get<1>(t1) == short('a'), ""); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp index b7fa2e3a03cc..4609b042556b 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp @@ -20,6 +20,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + struct Explicit { int value; explicit Explicit(int x) : value(x) {} @@ -43,7 +45,7 @@ struct D explicit D(int i) : B(i) {} }; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 struct A { @@ -66,17 +68,17 @@ struct C int main() { { - typedef std::tuple<double> T0; - typedef std::tuple<int> T1; - T0 t0(2.5); + typedef std::tuple<long> T0; + typedef std::tuple<long long> T1; + T0 t0(2); T1 t1 = t0; assert(std::get<0>(t1) == 2); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { - typedef std::tuple<double> T0; + typedef std::tuple<int> T0; typedef std::tuple<A> T1; - constexpr T0 t0(2.5); + constexpr T0 t0(2); constexpr T1 t1 = t0; static_assert(std::get<0>(t1) == 2, ""); } @@ -89,17 +91,17 @@ int main() } #endif { - typedef std::tuple<double, char> T0; - typedef std::tuple<int, int> T1; - T0 t0(2.5, 'a'); + typedef std::tuple<long, char> T0; + typedef std::tuple<long long, int> T1; + T0 t0(2, 'a'); T1 t1 = t0; assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); } { - typedef std::tuple<double, char, D> T0; - typedef std::tuple<int, int, B> T1; - T0 t0(2.5, 'a', D(3)); + typedef std::tuple<long, char, D> T0; + typedef std::tuple<long long, int, B> T1; + T0 t0(2, 'a', D(3)); T1 t1 = t0; assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); @@ -107,9 +109,9 @@ int main() } { D d(3); - typedef std::tuple<double, char, D&> T0; - typedef std::tuple<int, int, B&> T1; - T0 t0(2.5, 'a', d); + typedef std::tuple<long, char, D&> T0; + typedef std::tuple<long long, int, B&> T1; + T0 t0(2, 'a', d); T1 t1 = t0; d.id_ = 2; assert(std::get<0>(t1) == 2); @@ -117,9 +119,9 @@ int main() assert(std::get<2>(t1).id_ == 2); } { - typedef std::tuple<double, char, int> T0; - typedef std::tuple<int, int, B> T1; - T0 t0(2.5, 'a', 3); + typedef std::tuple<long, char, int> T0; + typedef std::tuple<long long, int, B> T1; + T0 t0(2, 'a', 3); T1 t1(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp index 8423f5d0145f..2af86fdd0868 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp @@ -48,24 +48,24 @@ struct D int main() { { - typedef std::tuple<double> T0; - typedef std::tuple<int> T1; - T0 t0(2.5); + typedef std::tuple<long> T0; + typedef std::tuple<long long> T1; + T0 t0(2); T1 t1 = std::move(t0); assert(std::get<0>(t1) == 2); } { - typedef std::tuple<double, char> T0; - typedef std::tuple<int, int> T1; - T0 t0(2.5, 'a'); + typedef std::tuple<long, char> T0; + typedef std::tuple<long long, int> T1; + T0 t0(2, 'a'); T1 t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); } { - typedef std::tuple<double, char, D> T0; - typedef std::tuple<int, int, B> T1; - T0 t0(2.5, 'a', D(3)); + typedef std::tuple<long, char, D> T0; + typedef std::tuple<long long, int, B> T1; + T0 t0(2, 'a', D(3)); T1 t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); @@ -73,9 +73,9 @@ int main() } { D d(3); - typedef std::tuple<double, char, D&> T0; - typedef std::tuple<int, int, B&> T1; - T0 t0(2.5, 'a', d); + typedef std::tuple<long, char, D&> T0; + typedef std::tuple<long long, int, B&> T1; + T0 t0(2, 'a', d); T1 t1 = std::move(t0); d.id_ = 2; assert(std::get<0>(t1) == 2); @@ -83,9 +83,9 @@ int main() assert(std::get<2>(t1).id_ == 2); } { - typedef std::tuple<double, char, std::unique_ptr<D>> T0; - typedef std::tuple<int, int, std::unique_ptr<B>> T1; - T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3))); + typedef std::tuple<long, char, std::unique_ptr<D>> T0; + typedef std::tuple<long long, int, std::unique_ptr<B>> T1; + T0 t0(2, 'a', std::unique_ptr<D>(new D(3))); T1 t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1) == int('a')); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp index 783c9d1f06a8..1137df2918dd 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp @@ -19,6 +19,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + struct Empty {}; int main() @@ -50,7 +52,7 @@ int main() assert(std::get<1>(t) == 'a'); assert(std::get<2>(t) == "some text"); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef std::tuple<int> T; constexpr T t0(2); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp new file mode 100644 index 000000000000..fbcda44e4065 --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/dtor.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 + +// <tuple> + +// template <class... Types> class tuple; + +// ~tuple(); + +#include <tuple> +#include <string> +#include <cassert> +#include <type_traits> + +int main() +{ + static_assert(std::is_trivially_destructible< + std::tuple<> >::value, ""); + static_assert(std::is_trivially_destructible< + std::tuple<void*> >::value, ""); + static_assert(std::is_trivially_destructible< + std::tuple<int, float> >::value, ""); + static_assert(!std::is_trivially_destructible< + std::tuple<std::string> >::value, ""); + static_assert(!std::is_trivially_destructible< + std::tuple<int, std::string> >::value, ""); +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp index 0c93673532bb..1cc13cf58ba8 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp @@ -29,7 +29,7 @@ struct ConstructsWithTupleLeaf ConstructsWithTupleLeaf(ConstructsWithTupleLeaf &&) {} template <class T> - ConstructsWithTupleLeaf(T t) { + ConstructsWithTupleLeaf(T) { static_assert(!std::is_same<T, T>::value, "Constructor instantiated for type other than int"); } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp index 2dfbaff6cc1a..13558f3fbe17 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp @@ -38,9 +38,9 @@ struct D int main() { { - typedef std::pair<double, std::unique_ptr<D>> T0; - typedef std::tuple<int, std::unique_ptr<B>> T1; - T0 t0(2.5, std::unique_ptr<D>(new D(3))); + typedef std::pair<long, std::unique_ptr<D>> T0; + typedef std::tuple<long long, std::unique_ptr<B>> T1; + T0 t0(2, std::unique_ptr<D>(new D(3))); T1 t1 = std::move(t0); assert(std::get<0>(t1) == 2); assert(std::get<1>(t1)->id_ == 3); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp index 2dbe81513a1a..1099e3579687 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/forward_as_tuple.pass.cpp @@ -18,6 +18,8 @@ #include <type_traits> #include <cassert> +#include "test_macros.h" + template <class Tuple> void test0(const Tuple&) @@ -54,7 +56,7 @@ test2a(const Tuple& t) assert(std::get<1>(t) == 'a'); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 template <class Tuple> constexpr int test3(const Tuple&) @@ -79,7 +81,7 @@ int main() double i = 2.5; char c = 'a'; test2a(std::forward_as_tuple(i, c)); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert ( test3 (std::forward_as_tuple(i, c)) == 2, "" ); #endif } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp index f27e8a09fb97..2c38bf7d230c 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp @@ -20,6 +20,8 @@ #include <functional> #include <cassert> +#include "test_macros.h" + int main() { { @@ -40,7 +42,7 @@ int main() assert(i == 0); assert(j == 0); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { constexpr auto t1 = std::make_tuple(0, 1, 3.14); constexpr int i1 = std::get<1>(t1); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp index 52ecd249402f..c4c3c242d8f8 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp @@ -20,6 +20,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + int main() { { @@ -29,7 +31,7 @@ int main() assert(i == 42); assert(s == "C++"); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { static constexpr int i = 42; static constexpr double f = 1.1; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp index 770edcaca5e1..18095f7e3033 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp @@ -21,6 +21,7 @@ #include <string> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" int main() @@ -48,7 +49,7 @@ int main() assert(std::get<0>(t) == 1); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { constexpr std::tuple<> t = std::tuple_cat(); ((void)t); // Prevent unused warning diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp index 002ad148ad6d..f014916742ad 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp @@ -21,6 +21,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + struct Empty {}; int main() @@ -36,7 +38,7 @@ int main() assert(std::get<0>(t) == "high"); assert(std::get<1>(t) == 5); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef std::tuple<double, int> T; constexpr T t(2.718, 5); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp index 58df2df7679a..9c2d992b8e49 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp @@ -19,7 +19,7 @@ #include <tuple> -template <class T> void cref(T const&) {}; +template <class T> void cref(T const&) {} template <class T> void cref(T const&&) = delete; std::tuple<int> const tup4() { return std::make_tuple(4); } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp index 86d1191db556..fc53412899fb 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp @@ -71,7 +71,7 @@ int main() assert(std::get<2>(t) == 4); assert(d == 2.5); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { // get on an rvalue tuple static_assert ( std::get<0> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 0, "" ); static_assert ( std::get<1> ( std::make_tuple ( 0.0f, 1, 2.0, 3L )) == 1, "" ); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp index 42e4fab88ffa..5beedbe9d157 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp @@ -23,6 +23,8 @@ #include <tuple> #include <type_traits> +#include "test_macros.h" + template <class T, std::size_t N, class U> void test() { @@ -30,7 +32,7 @@ void test() static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), ""); static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), ""); static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), ""); static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), ""); static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), ""); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp index 3f132e47b626..50c6f17efbef 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp @@ -21,7 +21,7 @@ int main() { - (void)std::tuple_size<std::tuple<> &>::value; // expected-error {{implicit instantiation of undefined template}} - (void)std::tuple_size<int>::value; // expected-error {{implicit instantiation of undefined template}} - (void)std::tuple_size<std::tuple<>*>::value; // expected-error {{implicit instantiation of undefined template}} + (void)std::tuple_size<std::tuple<> &>::value; // expected-error {{no member named 'value'}} + (void)std::tuple_size<int>::value; // expected-error {{no member named 'value'}} + (void)std::tuple_size<std::tuple<>*>::value; // expected-error {{no member named 'value'}} } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp index 49b4215a1956..40214f632e75 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp @@ -18,19 +18,36 @@ // UNSUPPORTED: c++98, c++03 #include <tuple> +#include <utility> +#include <array> #include <type_traits> +template <class T, class = decltype(std::tuple_size<T>::value)> +constexpr bool has_value(int) { return true; } +template <class> constexpr bool has_value(long) { return false; } +template <class T> constexpr bool has_value() { return has_value<T>(0); } + + template <class T, std::size_t N> void test() { + static_assert(has_value<T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<T> >::value), ""); + static_assert(has_value<const T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<const T> >::value), ""); + static_assert(has_value<volatile T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<volatile T> >::value), ""); + + static_assert(has_value<const volatile T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<const volatile T> >::value), ""); + { + static_assert(!has_value<T &>(), ""); + static_assert(!has_value<T *>(), ""); + } } int main() @@ -39,4 +56,13 @@ int main() test<std::tuple<int>, 1>(); test<std::tuple<char, int>, 2>(); test<std::tuple<char, char*, int>, 3>(); + test<std::pair<int, void*>, 2>(); + test<std::array<int, 42>, 42>(); + { + static_assert(!has_value<void>(), ""); + static_assert(!has_value<void*>(), ""); + static_assert(!has_value<int>(), ""); + static_assert(!has_value<std::pair<int, int>*>(), ""); + static_assert(!has_value<std::array<int, 42>&>(), ""); + } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp index 957a683b47f8..700dd95c959c 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp @@ -22,5 +22,5 @@ int main() (void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}} (void)std::tuple_size_v<int>; // expected-note {{requested here}} (void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}} - // expected-error@tuple:* 3 {{implicit instantiation of undefined template}} + // expected-error@tuple:* 3 {{no member named 'value'}} } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp index e5991df636f8..a802a05da2bc 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp @@ -21,6 +21,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + int main() { { @@ -49,104 +51,104 @@ int main() } { typedef std::tuple<int, double> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); - const T2 t2(1, char(2)); + const T2 t2(1, 2); assert(t1 == t2); assert(!(t1 != t2)); } { typedef std::tuple<int, double> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); - const T2 t2(1, char(3)); + const T2 t2(1, 3); assert(!(t1 == t2)); assert(t1 != t2); } { typedef std::tuple<int, double> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); - const T2 t2(1.1, char(2)); + const T2 t2(1.1, 2); assert(!(t1 == t2)); assert(t1 != t2); } { typedef std::tuple<int, double> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); - const T2 t2(1.1, char(3)); + const T2 t2(1.1, 3); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 2, 3); assert(t1 == t2); assert(!(t1 != t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1.1, 2, 3); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 3, 3); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 2, 4); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 3, 2); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1.1, 2, 2); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1.1, 3, 3); assert(!(t1 == t2)); assert(t1 != t2); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1.1, 3, 2); assert(!(t1 == t2)); assert(t1 != t2); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; constexpr T1 t1(1, 2, 3); constexpr T2 t2(1.1, 3, 2); static_assert(!(t1 == t2), ""); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp index 34aafb1e1347..f4d764b87ee9 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp @@ -33,6 +33,8 @@ #include <string> #include <cassert> +#include "test_macros.h" + int main() { { @@ -46,7 +48,7 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char> T1; + typedef std::tuple<long> T1; typedef std::tuple<double> T2; const T1 t1(1); const T2 t2(1); @@ -56,7 +58,7 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char> T1; + typedef std::tuple<long> T1; typedef std::tuple<double> T2; const T1 t1(1); const T2 t2(0.9); @@ -66,7 +68,7 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char> T1; + typedef std::tuple<long> T1; typedef std::tuple<double> T2; const T1 t1(1); const T2 t2(1.1); @@ -76,8 +78,8 @@ int main() assert(!(t1 >= t2)); } { - typedef std::tuple<char, int> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<long, int> T1; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); const T2 t2(1, 2); assert(!(t1 < t2)); @@ -86,8 +88,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<long, int> T1; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); const T2 t2(0.9, 2); assert(!(t1 < t2)); @@ -96,8 +98,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<long, int> T1; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); const T2 t2(1.1, 2); assert( (t1 < t2)); @@ -106,8 +108,8 @@ int main() assert(!(t1 >= t2)); } { - typedef std::tuple<char, int> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<long, int> T1; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); const T2 t2(1, 1); assert(!(t1 < t2)); @@ -116,8 +118,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int> T1; - typedef std::tuple<double, char> T2; + typedef std::tuple<long, int> T1; + typedef std::tuple<double, long> T2; const T1 t1(1, 2); const T2 t2(1, 3); assert( (t1 < t2)); @@ -126,8 +128,8 @@ int main() assert(!(t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 2, 3); assert(!(t1 < t2)); @@ -136,8 +138,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(0.9, 2, 3); assert(!(t1 < t2)); @@ -146,8 +148,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1.1, 2, 3); assert( (t1 < t2)); @@ -156,8 +158,8 @@ int main() assert(!(t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 1, 3); assert(!(t1 < t2)); @@ -166,8 +168,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 3, 3); assert( (t1 < t2)); @@ -176,8 +178,8 @@ int main() assert(!(t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 2, 2); assert(!(t1 < t2)); @@ -186,8 +188,8 @@ int main() assert( (t1 >= t2)); } { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; const T1 t1(1, 2, 3); const T2 t2(1, 2, 4); assert( (t1 < t2)); @@ -195,10 +197,10 @@ int main() assert(!(t1 > t2)); assert(!(t1 >= t2)); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { - typedef std::tuple<char, int, double> T1; - typedef std::tuple<double, char, int> T2; + typedef std::tuple<long, int, double> T1; + typedef std::tuple<double, long, int> T2; constexpr T1 t1(1, 2, 3); constexpr T2 t2(1, 2, 4); static_assert( (t1 < t2), ""); |