From: Marshall Clow Date: Mon, 17 Nov 2014 15:04:46 +0000 (+0000) Subject: Add tests to ensure that reference_wrapper is trivially copyable. This was added... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a8c46653f15350abf326fbf46d7b91cc976671d;p=platform%2Fupstream%2Fllvm.git Add tests to ensure that reference_wrapper is trivially copyable. This was added to C++1z with the adoption of N4277, but libc++ already implemented it as a conforming extension. No code changes were needed, just more tests. llvm-svn: 222132 --- diff --git a/libcxx/test/utilities/function.objects/refwrap/type_properties.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/type_properties.pass.cpp index 7df692b..61e0bfa 100644 --- a/libcxx/test/utilities/function.objects/refwrap/type_properties.pass.cpp +++ b/libcxx/test/utilities/function.objects/refwrap/type_properties.pass.cpp @@ -16,12 +16,43 @@ #include #include +#include -int main() +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +class MoveOnly +{ + MoveOnly(const MoveOnly&); + MoveOnly& operator=(const MoveOnly&); + + int data_; +public: + MoveOnly(int data = 1) : data_(data) {} + MoveOnly(MoveOnly&& x) + : data_(x.data_) {x.data_ = 0;} + MoveOnly& operator=(MoveOnly&& x) + {data_ = x.data_; x.data_ = 0; return *this;} + + int get() const {return data_;} +}; +#endif + + +template +void test() { - typedef std::reference_wrapper T; - static_assert(std::is_copy_constructible::value, ""); - static_assert(std::is_copy_assignable::value, ""); + typedef std::reference_wrapper Wrap; + static_assert(std::is_copy_constructible::value, ""); + static_assert(std::is_copy_assignable::value, ""); // Extension up for standardization: See N4151. - static_assert(std::is_trivially_copyable::value, ""); + static_assert(std::is_trivially_copyable::value, ""); +} + +int main() +{ + test(); + test(); + test(); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + test(); +#endif }