diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2013-10-05 23:29:16 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2013-10-05 23:29:16 +0000 |
commit | d2f095e5bab4c2df2d94e1d0f4e7637f35a828f6 (patch) | |
tree | c9ec830ba193eae1964b1a066bcd43ab0a62dd44 /libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp | |
parent | 4c9b7dc92e22f58f7a621e72bb6a90d77d986ef3 (diff) | |
download | bcm5719-llvm-d2f095e5bab4c2df2d94e1d0f4e7637f35a828f6.tar.gz bcm5719-llvm-d2f095e5bab4c2df2d94e1d0f4e7637f35a828f6.zip |
Add tests making sure that optional<T>s can be compared at compile time; this functionality was enabled by N3789
llvm-svn: 192051
Diffstat (limited to 'libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp')
-rw-r--r-- | libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp index b1865fafe74..81150ad2c5a 100644 --- a/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp +++ b/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp @@ -14,11 +14,25 @@ #include <optional> +#if _LIBCPP_STD_VER > 11 + +struct X +{ + int i_; + + constexpr X(int i) : i_(i) {} +}; + +constexpr bool operator == ( const X &rhs, const X &lhs ) + { return rhs.i_ == lhs.i_ ; } + +#endif + int main() { #if _LIBCPP_STD_VER > 11 { - typedef int T; + typedef X T; typedef std::optional<T> O; constexpr T val(2); @@ -26,16 +40,16 @@ int main() constexpr O o2{1}; // engaged constexpr O o3{val}; // engaged - static_assert ( !(o1 == 1), "" ); - static_assert ( o2 == 1, "" ); - static_assert ( !(o3 == 1), "" ); - static_assert ( o3 == 2 , "" ); + static_assert ( !(o1 == T(1)), "" ); + static_assert ( o2 == T(1), "" ); + static_assert ( !(o3 == T(1)), "" ); + static_assert ( o3 == T(2) , "" ); static_assert ( o3 == val, "" ); - static_assert ( !(1 == o1), "" ); - static_assert ( 1 == o2, "" ); - static_assert ( !(1 == o3), "" ); - static_assert ( 2 == o3 , "" ); + static_assert ( !(T(1) == o1), "" ); + static_assert ( T(1) == o2, "" ); + static_assert ( !(T(1) == o3), "" ); + static_assert ( T(2) == o3 , "" ); static_assert ( val == o3 , "" ); } #endif |