Add tests making sure that optional<T>s can be compared at compile time; this functionality was enabled by N3789
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@192051 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,11 +15,25 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
#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 O o1; // disengaged
|
||||
|
||||
@@ -22,21 +22,8 @@ struct X
|
||||
constexpr X(int i) : i_(i) {}
|
||||
};
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template <>
|
||||
struct less<X>
|
||||
{
|
||||
constexpr
|
||||
bool
|
||||
operator()(const X& x, const X& y) const
|
||||
{
|
||||
return x.i_ < y.i_;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
constexpr bool operator < ( const X &rhs, const X &lhs )
|
||||
{ return rhs.i_ < lhs.i_ ; }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user