diff options
Diffstat (limited to 'libcxx/test/std')
3 files changed, 94 insertions, 6 deletions
diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp index d16313fe7eb..1117db3297b 100644 --- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp @@ -13,9 +13,6 @@ // pair(const pair&) = default; -// Doesn't pass due to use of is_trivially_* trait. -// XFAIL: gcc-4.9 - #include <utility> #include <cassert> @@ -30,9 +27,6 @@ int main() assert(p2.first == 3); assert(p2.second == 4); } - - static_assert((std::is_trivially_copy_constructible<std::pair<int, int> >::value), ""); - #if TEST_STD_VER > 11 { typedef std::pair<int, short> P1; diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp new file mode 100644 index 00000000000..06cb5e5658c --- /dev/null +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// <utility> + +// template <class T1, class T2> struct pair + +// pair(pair&&) = default; + +#include <utility> +#include <memory> +#include <cassert> + +#include "test_macros.h" + +struct Dummy { + Dummy(Dummy const&) = delete; + Dummy(Dummy &&) = default; +}; + +int main() +{ + { + typedef std::pair<int, short> P1; + static_assert(std::is_move_constructible<P1>::value, ""); + P1 p1(3, 4); + P1 p2 = std::move(p1); + assert(p2.first == 3); + assert(p2.second == 4); + } + { + using P = std::pair<Dummy, int>; + static_assert(!std::is_copy_constructible<P>::value, ""); + static_assert(std::is_move_constructible<P>::value, ""); + } +} diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp new file mode 100644 index 00000000000..53cf56700df --- /dev/null +++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/trivial_copy_move.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <utility> + +// template <class T1, class T2> struct pair + +// pair(pair const&) = default; +// pair(pair&&) = default; + +// Doesn't pass due to use of is_trivially_* trait. +// XFAIL: gcc-4.9 + +#include <utility> +#include <cassert> + +#include "test_macros.h" + +struct Dummy { + Dummy(Dummy const&) = delete; + Dummy(Dummy &&) = default; +}; + +int main() +{ + typedef std::pair<int, short> P; + { + static_assert(std::is_copy_constructible<P>::value, ""); + static_assert(std::is_trivially_copy_constructible<P>::value, ""); + } +#if TEST_STD_VER >= 11 + { + static_assert(std::is_move_constructible<P>::value, ""); + static_assert(std::is_trivially_move_constructible<P>::value, ""); + } + { + using P1 = std::pair<Dummy, int>; + static_assert(!std::is_copy_constructible<P1>::value, ""); + static_assert(!std::is_trivially_copy_constructible<P1>::value, ""); + static_assert(std::is_move_constructible<P1>::value, ""); + static_assert(std::is_trivially_move_constructible<P1>::value, ""); + } +#endif +} |

