From 61b9a7258a7693d7f3674a5a1daf7b036ff1d382 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 6 Sep 2015 18:46:46 +0000 Subject: Import libc++ 3.7.0 release (r246257). --- .../arithmetic.operations/divides.pass.cpp | 39 ++++++++++++++ .../arithmetic.operations/minus.pass.cpp | 39 ++++++++++++++ .../arithmetic.operations/modulus.pass.cpp | 39 ++++++++++++++ .../arithmetic.operations/multiplies.pass.cpp | 39 ++++++++++++++ .../arithmetic.operations/negate.pass.cpp | 38 ++++++++++++++ .../arithmetic.operations/plus.pass.cpp | 39 ++++++++++++++ .../arithmetic.operations/transparent.pass.cpp | 61 ++++++++++++++++++++++ 7 files changed, 294 insertions(+) create mode 100644 test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp create mode 100644 test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp (limited to 'test/std/utilities/function.objects/arithmetic.operations') diff --git a/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp new file mode 100644 index 0000000000000..490dc16b60e21 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// divides + +#include +#include +#include + +int main() +{ + typedef std::divides F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(36, 4) == 9); +#if _LIBCPP_STD_VER > 11 + typedef std::divides<> F2; + const F2 f2 = F2(); + assert(f2(36, 4) == 9); + assert(f2(36.0, 4) == 9); + assert(f2(18, 4.0) == 4.5); // exact in binary + + constexpr int foo = std::divides () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::divides<> () (3.0, 2); + static_assert ( bar == 1, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp new file mode 100644 index 0000000000000..9bda541f896a8 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// minus + +#include +#include +#include + +int main() +{ + typedef std::minus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(3, 2) == 1); +#if _LIBCPP_STD_VER > 11 + typedef std::minus<> F2; + const F2 f2 = F2(); + assert(f2(3,2) == 1); + assert(f2(3.0, 2) == 1); + assert(f2(3, 2.5) == 0.5); + + constexpr int foo = std::minus () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::minus<> () (3.0, 2); + static_assert ( bar == 1, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp new file mode 100644 index 0000000000000..ca5bba6d5b8ea --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/modulus.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// modulus + +#include +#include +#include + +int main() +{ + typedef std::modulus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(36, 8) == 4); +#if _LIBCPP_STD_VER > 11 + typedef std::modulus<> F2; + const F2 f2 = F2(); + assert(f2(36, 8) == 4); + assert(f2(36L, 8) == 4); + assert(f2(36, 8L) == 4); + + constexpr int foo = std::modulus () (3, 2); + static_assert ( foo == 1, "" ); + + constexpr int bar = std::modulus<> () (3L, 2); + static_assert ( bar == 1, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp new file mode 100644 index 0000000000000..f132c8d4bd9b2 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// multiplies + +#include +#include +#include + +int main() +{ + typedef std::multiplies F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(3, 2) == 6); +#if _LIBCPP_STD_VER > 11 + typedef std::multiplies<> F2; + const F2 f2 = F2(); + assert(f2(3,2) == 6); + assert(f2(3.0, 2) == 6); + assert(f2(3, 2.5) == 7.5); // exact in binary + + constexpr int foo = std::multiplies () (3, 2); + static_assert ( foo == 6, "" ); + + constexpr int bar = std::multiplies<> () (3.0, 2); + static_assert ( bar == 6, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp new file mode 100644 index 0000000000000..0adac659123b4 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// negate + +#include +#include +#include + +int main() +{ + typedef std::negate F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(36) == -36); +#if _LIBCPP_STD_VER > 11 + typedef std::negate<> F2; + const F2 f2 = F2(); + assert(f2(36) == -36); + assert(f2(36L) == -36); + assert(f2(36.0) == -36); + + constexpr int foo = std::negate () (3); + static_assert ( foo == -3, "" ); + + constexpr int bar = std::negate<> () (3.0); + static_assert ( bar == -3, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp new file mode 100644 index 0000000000000..3c093fc093c32 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// + +// plus + +#include +#include +#include + +int main() +{ + typedef std::plus F; + const F f = F(); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + static_assert((std::is_same::value), "" ); + assert(f(3, 2) == 5); +#if _LIBCPP_STD_VER > 11 + typedef std::plus<> F2; + const F2 f2 = F2(); + assert(f2(3,2) == 5); + assert(f2(3.0, 2) == 5); + assert(f2(3, 2.5) == 5.5); + + constexpr int foo = std::plus () (3, 2); + static_assert ( foo == 5, "" ); + + constexpr int bar = std::plus<> () (3.0, 2); + static_assert ( bar == 5, "" ); +#endif +} diff --git a/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp b/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp new file mode 100644 index 0000000000000..72b4b4a0a1fe7 --- /dev/null +++ b/test/std/utilities/function.objects/arithmetic.operations/transparent.pass.cpp @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +#include +#include + +template +struct is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::is_transparent* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + + +int main () { +#if _LIBCPP_STD_VER > 11 + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + + static_assert ( !is_transparent>::value, "" ); + static_assert ( !is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + static_assert ( is_transparent>::value, "" ); + +#endif + + return 0; + } -- cgit v1.2.3