Skip to content

Commit

Permalink
Remove <experimental/numeric>; use <numeric> instead. See https://lib…
Browse files Browse the repository at this point in the history
  • Loading branch information
mclow committed Feb 1, 2018
1 parent 7ae53e8 commit 91af904
Show file tree
Hide file tree
Showing 20 changed files with 1 addition and 720 deletions.
110 changes: 1 addition & 109 deletions libcxx/include/experimental/numeric
Original file line number Diff line number Diff line change
Expand Up @@ -8,112 +8,4 @@
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
#define _LIBCPP_EXPERIMENTAL_NUMERIC
/*
experimental/numeric synopsis
// C++1z
namespace std {
namespace experimental {
inline namespace fundamentals_v2 {
// 13.1.2, Greatest common divisor
template<class M, class N>
constexpr common_type_t<M,N> gcd(M m, N n);
// 13.1.3, Least common multiple
template<class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n);
} // namespace fundamentals_v2
} // namespace experimental
} // namespace std
*/

#include <experimental/__config>
#include <numeric>
#include <type_traits> // is_integral
#include <limits> // numeric_limits

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

#if _LIBCPP_STD_VER > 11

_LIBCPP_BEGIN_NAMESPACE_LFTS_V2

template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;

template <typename _Result, typename _Source>
struct __abs<_Result, _Source, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept
{
if (__t >= 0) return __t;
if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t);
return -__t;
}
};

template <typename _Result, typename _Source>
struct __abs<_Result, _Source, false> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept { return __t; }
};


template<class _Tp>
_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
inline _Tp __gcd(_Tp __m, _Tp __n)
{
static_assert((!is_signed<_Tp>::value), "" );
return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
}


template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
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>(_VSTD_LFTS_V2::__gcd(
static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
}

template<class _Tp, class _Up>
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
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;

using _Rp = common_type_t<_Tp,_Up>;
_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
_Rp __val2 = __abs<_Rp, _Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
}

_LIBCPP_END_NAMESPACE_LFTS_V2

#endif /* _LIBCPP_STD_VER > 11 */

_LIBCPP_POP_MACROS

#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */
#error "<experimental/numeric> has been removed. Use <numeric> instead."
4 changes: 0 additions & 4 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,6 @@ module std [system] {
header "experimental/memory_resource"
export *
}
module numeric {
header "experimental/numeric"
export *
}
module propagate_const {
header "experimental/propagate_const"
export *
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/double_include.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
#include <experimental/list>
#include <experimental/map>
#include <experimental/memory_resource>
#include <experimental/numeric>
#include <experimental/propagate_const>
#include <experimental/ratio>
#include <experimental/regex>
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/min_max_macros.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ TEST_MACROS();
TEST_MACROS();
#include <experimental/memory_resource>
TEST_MACROS();
#include <experimental/numeric>
TEST_MACROS();
#include <experimental/propagate_const>
TEST_MACROS();
#include <experimental/ratio>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 91af904

Please sign in to comment.