Implement LWG2733: [fund.ts.v2] gcd / lcm and bool. We already did tbis for C++17, so replicate the changes in experimental.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -75,6 +75,8 @@ common_type_t<_Tp,_Up>
|
||||
gcd(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" );
|
||||
using _Rp = common_type_t<_Tp,_Up>;
|
||||
using _Wp = make_unsigned_t<_Rp>;
|
||||
return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)),
|
||||
@@ -87,6 +89,8 @@ common_type_t<_Tp,_Up>
|
||||
lcm(_Tp __m, _Up __n)
|
||||
{
|
||||
static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
|
||||
static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" );
|
||||
static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" );
|
||||
if (__m == 0 || __n == 0)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::gcd(false, 4);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::gcd(2, true);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::gcd<volatile bool, int>(false, 4);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::gcd<int, const bool>(2, true);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::lcm(false, 4);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::lcm(2, true);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::lcm<volatile bool, int>(false, 4);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
// <numeric>
|
||||
|
||||
// template<class _M, class _N>
|
||||
// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
|
||||
|
||||
// Remarks: If either M or N is not an integer type,
|
||||
// or if either is (a possibly cv-qualified) bool, the program is ill-formed.
|
||||
|
||||
#include <experimental/numeric>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::experimental::lcm<int, const bool>(2, true);
|
||||
}
|
||||
Reference in New Issue
Block a user