Skip to content

Commit

Permalink
Revert "[libc++] P1645 constexpr for <numeric>"
Browse files Browse the repository at this point in the history
This reverts commit eb9b063.

The commit fails to build on build bots using LLVM 8.
  • Loading branch information
mordante committed Nov 25, 2020
1 parent ed242da commit ecabb39
Show file tree
Hide file tree
Showing 30 changed files with 245 additions and 804 deletions.
2 changes: 0 additions & 2 deletions libcxx/docs/FeatureTestMacroTable.rst
Expand Up @@ -196,8 +196,6 @@ Status
------------------------------------------------- -----------------
``__cpp_lib_constexpr_misc`` *unimplemented*
------------------------------------------------- -----------------
``__cpp_lib_constexpr_numeric`` ``201911L``
------------------------------------------------- -----------------
``__cpp_lib_constexpr_swap_algorithms`` *unimplemented*
------------------------------------------------- -----------------
``__cpp_lib_constexpr_utility`` ``201811L``
Expand Down
102 changes: 46 additions & 56 deletions libcxx/include/numeric

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions libcxx/include/version
Expand Up @@ -48,7 +48,6 @@ __cpp_lib_concepts 201806L <concepts>
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_misc 201811L <array> <functional> <iterator>
<string_view> <tuple> <utility>
__cpp_lib_constexpr_numeric 201911L <numeric>
__cpp_lib_constexpr_swap_algorithms 201806L <algorithm>
__cpp_lib_constexpr_utility 201811L <utility>
__cpp_lib_destroying_delete 201806L <new>
Expand Down Expand Up @@ -255,7 +254,6 @@ __cpp_lib_void_t 201411L <type_traits>
// # define __cpp_lib_concepts 201806L
# define __cpp_lib_constexpr_dynamic_alloc 201907L
// # define __cpp_lib_constexpr_misc 201811L
# define __cpp_lib_constexpr_numeric 201911L
// # define __cpp_lib_constexpr_swap_algorithms 201806L
# define __cpp_lib_constexpr_utility 201811L
# if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
Expand Down
Expand Up @@ -14,7 +14,6 @@
// Test the feature test macros defined by <numeric>

/* Constant Value
__cpp_lib_constexpr_numeric 201911L [C++2a]
__cpp_lib_gcd_lcm 201606L [C++17]
__cpp_lib_interpolate 201902L [C++2a]
__cpp_lib_parallel_algorithm 201603L [C++17]
Expand All @@ -25,10 +24,6 @@

#if TEST_STD_VER < 14

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifdef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should not be defined before c++17"
# endif
Expand All @@ -43,10 +38,6 @@

#elif TEST_STD_VER == 14

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifdef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should not be defined before c++17"
# endif
Expand All @@ -61,10 +52,6 @@

#elif TEST_STD_VER == 17

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifndef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should be defined in c++17"
# endif
Expand All @@ -91,13 +78,6 @@

#elif TEST_STD_VER > 17

# ifndef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should be defined in c++2a"
# endif
# if __cpp_lib_constexpr_numeric != 201911L
# error "__cpp_lib_constexpr_numeric should have the value 201911L in c++2a"
# endif

# ifndef __cpp_lib_gcd_lcm
# error "__cpp_lib_gcd_lcm should be defined in c++2a"
# endif
Expand Down
Expand Up @@ -42,7 +42,6 @@
__cpp_lib_concepts 201806L [C++2a]
__cpp_lib_constexpr_dynamic_alloc 201907L [C++2a]
__cpp_lib_constexpr_misc 201811L [C++2a]
__cpp_lib_constexpr_numeric 201911L [C++2a]
__cpp_lib_constexpr_swap_algorithms 201806L [C++2a]
__cpp_lib_constexpr_utility 201811L [C++2a]
__cpp_lib_destroying_delete 201806L [C++2a]
Expand Down Expand Up @@ -228,10 +227,6 @@
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
Expand Down Expand Up @@ -624,10 +619,6 @@
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
Expand Down Expand Up @@ -1134,10 +1125,6 @@
# error "__cpp_lib_constexpr_misc should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should not be defined before c++2a"
# endif

# ifdef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should not be defined before c++2a"
# endif
Expand Down Expand Up @@ -1923,13 +1910,6 @@
# endif
# endif

# ifndef __cpp_lib_constexpr_numeric
# error "__cpp_lib_constexpr_numeric should be defined in c++2a"
# endif
# if __cpp_lib_constexpr_numeric != 201911L
# error "__cpp_lib_constexpr_numeric should have the value 201911L in c++2a"
# endif

# if !defined(_LIBCPP_VERSION)
# ifndef __cpp_lib_constexpr_swap_algorithms
# error "__cpp_lib_constexpr_swap_algorithms should be defined in c++2a"
Expand Down
Expand Up @@ -8,7 +8,6 @@

// <numeric>

// Became constexpr in C++20
// template <InputIterator Iter, MoveConstructible T>
// requires HasPlus<T, Iter::reference>
// && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
Expand All @@ -22,14 +21,14 @@
#include "test_iterators.h"

template <class Iter, class T>
TEST_CONSTEXPR_CXX20 void
void
test(Iter first, Iter last, T init, T x)
{
assert(std::accumulate(first, last, init) == x);
}

template <class Iter>
TEST_CONSTEXPR_CXX20 void
void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
Expand All @@ -44,23 +43,13 @@ test()
test(Iter(ia), Iter(ia+sa), 10, 31);
}

TEST_CONSTEXPR_CXX20 bool
test()
int main(int, char**)
{
test<input_iterator<const int*> >();
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();

return true;
}

int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
return 0;
}
Expand Up @@ -8,7 +8,6 @@

// <numeric>

// Became constexpr in C++20
// template <InputIterator Iter, MoveConstructible T,
// Callable<auto, const T&, Iter::reference> BinaryOperation>
// requires HasAssign<T, BinaryOperation::result_type>
Expand All @@ -24,14 +23,14 @@
#include "test_iterators.h"

template <class Iter, class T>
TEST_CONSTEXPR_CXX20 void
void
test(Iter first, Iter last, T init, T x)
{
assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
}

template <class Iter>
TEST_CONSTEXPR_CXX20 void
void
test()
{
int ia[] = {1, 2, 3, 4, 5, 6};
Expand All @@ -46,23 +45,13 @@ test()
test(Iter(ia), Iter(ia+sa), 10, 7200);
}

TEST_CONSTEXPR_CXX20 bool
test()
int main(int, char**)
{
test<input_iterator<const int*> >();
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();

return true;
}

int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
return 0;
}
Expand Up @@ -8,7 +8,6 @@

// <numeric>

// Became constexpr in C++20
// template <InputIterator InIter,
// OutputIterator<auto, const InIter::value_type&> OutIter>
// requires HasMinus<InIter::value_type, InIter::value_type>
Expand All @@ -26,7 +25,7 @@
#include "test_iterators.h"

template <class InIter, class OutIter>
TEST_CONSTEXPR_CXX20 void
void
test()
{
int ia[] = {15, 10, 6, 3, 1};
Expand All @@ -47,18 +46,18 @@ class X
{
int i_;

TEST_CONSTEXPR_CXX20 X& operator=(const X&);
X& operator=(const X&);
public:
TEST_CONSTEXPR_CXX20 explicit X(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 X(const X& x) : i_(x.i_) {}
TEST_CONSTEXPR_CXX20 X& operator=(X&& x)
explicit X(int i) : i_(i) {}
X(const X& x) : i_(x.i_) {}
X& operator=(X&& x)
{
i_ = x.i_;
x.i_ = -1;
return *this;
}

TEST_CONSTEXPR_CXX20 friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}

friend class Y;
};
Expand All @@ -67,17 +66,16 @@ class Y
{
int i_;

TEST_CONSTEXPR_CXX20 Y& operator=(const Y&);
Y& operator=(const Y&);
public:
TEST_CONSTEXPR_CXX20 explicit Y(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 Y(const Y& y) : i_(y.i_) {}
TEST_CONSTEXPR_CXX20 void operator=(const X& x) {i_ = x.i_;}
explicit Y(int i) : i_(i) {}
Y(const Y& y) : i_(y.i_) {}
void operator=(const X& x) {i_ = x.i_;}
};

#endif

TEST_CONSTEXPR_CXX20 bool
test()
int main(int, char**)
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
Expand Down Expand Up @@ -115,14 +113,5 @@ test()
std::adjacent_difference(x, x+3, y);
#endif

return true;
}

int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
return 0;
}
Expand Up @@ -8,7 +8,6 @@

// <numeric>

// Became constexpr in C++20
// template <InputIterator InIter,
// OutputIterator<auto, const InIter::value_type&> OutIter,
// Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
Expand All @@ -27,7 +26,7 @@
#include "test_iterators.h"

template <class InIter, class OutIter>
TEST_CONSTEXPR_CXX20 void
void
test()
{
int ia[] = {15, 10, 6, 3, 1};
Expand All @@ -49,18 +48,18 @@ class X
{
int i_;

TEST_CONSTEXPR_CXX20 X& operator=(const X&);
X& operator=(const X&);
public:
TEST_CONSTEXPR_CXX20 explicit X(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 X(const X& x) : i_(x.i_) {}
TEST_CONSTEXPR_CXX20 X& operator=(X&& x)
explicit X(int i) : i_(i) {}
X(const X& x) : i_(x.i_) {}
X& operator=(X&& x)
{
i_ = x.i_;
x.i_ = -1;
return *this;
}

TEST_CONSTEXPR_CXX20 friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}

friend class Y;
};
Expand All @@ -69,18 +68,17 @@ class Y
{
int i_;

TEST_CONSTEXPR_CXX20 Y& operator=(const Y&);
Y& operator=(const Y&);
public:
TEST_CONSTEXPR_CXX20 explicit Y(int i) : i_(i) {}
TEST_CONSTEXPR_CXX20 Y(const Y& y) : i_(y.i_) {}
TEST_CONSTEXPR_CXX20 void operator=(const X& x) {i_ = x.i_;}
explicit Y(int i) : i_(i) {}
Y(const Y& y) : i_(y.i_) {}
void operator=(const X& x) {i_ = x.i_;}
};

#endif


TEST_CONSTEXPR_CXX20 bool
test()
int main(int, char**)
{
test<input_iterator<const int*>, output_iterator<int*> >();
test<input_iterator<const int*>, forward_iterator<int*> >();
Expand Down Expand Up @@ -118,14 +116,5 @@ test()
std::adjacent_difference(x, x+3, y, std::minus<X>());
#endif

return true;
}

int main(int, char**)
{
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
return 0;
}

0 comments on commit ecabb39

Please sign in to comment.