[libcxx] Add <experimental/ratio>
Summary: This patch is pretty simple. It just adds the _v traits from <ratio>. The draft can be found here. Reviewers: jroelofs, K-ballo, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7351 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@229509 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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, c++11
|
||||
|
||||
// <experimental/ratio>
|
||||
|
||||
// template <class R1, class R2> constexpr bool ratio_less_v;
|
||||
|
||||
#include <experimental/ratio>
|
||||
#include <type_traits>
|
||||
|
||||
namespace ex = std::experimental;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
typedef std::ratio<1, 2> R1;
|
||||
typedef std::ratio<1, 1> R2;
|
||||
static_assert(
|
||||
ex::ratio_less_v<R1, R2>, ""
|
||||
);
|
||||
static_assert(
|
||||
ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
|
||||
);
|
||||
static_assert(
|
||||
std::is_same<decltype(ex::ratio_less_v<R1, R2>), const bool>::value
|
||||
, ""
|
||||
);
|
||||
}
|
||||
{
|
||||
typedef std::ratio<1, 1> R1;
|
||||
typedef std::ratio<1, 1> R2;
|
||||
static_assert(
|
||||
!ex::ratio_less_v<R1, R2>, ""
|
||||
);
|
||||
static_assert(
|
||||
ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
|
||||
);
|
||||
}
|
||||
{
|
||||
typedef std::ratio<2, 1> R1;
|
||||
typedef std::ratio<1, 1> R2;
|
||||
static_assert(
|
||||
!ex::ratio_less_v<R1, R2>, ""
|
||||
);
|
||||
static_assert(
|
||||
ex::ratio_less_v<R1, R2> == std::ratio_less<R1, R2>::value, ""
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user