binary_search(ForwardIterator first, ForwardIterator last, const T& value);
template <class ForwardIterator, class T, class Compare>
- bool // constexpr in C++20
+ constexpr bool // constexpr in C++20
binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
template <class InputIterator1, class InputIterator2>
- bool
+ constexpr bool // constexpr in C++20
includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
template <class InputIterator1, class InputIterator2, class Compare>
- bool
+ constexpr bool // constexpr in C++20
includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
template <class InputIterator1, class InputIterator2, class OutputIterator>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result);
template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
- OutputIterator
+ constexpr OutputIterator // constexpr in C++20
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
// includes
template <class _Compare, class _InputIterator1, class _InputIterator2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_Compare __comp)
{
}
template <class _InputIterator1, class _InputIterator2, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_Compare __comp)
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
{
// set_intersection
template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator>
-_OutputIterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator
__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result)
#if _LIBCPP_STD_VER > 11
template<class _T1, class _T2 = _T1>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_T1 exchange(_T1& __obj, _T2 && __new_value)
{
_T1 __old_value = _VSTD::move(__obj);
// template<InputIterator Iter1, InputIterator Iter2>
// requires HasLess<Iter1::value_type, Iter2::value_type>
// && HasLess<Iter2::value_type, Iter1::value_type>
-// bool
+// constexpr bool // constexpr after C++17
// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ int ib[] = {2, 4};
+ int ic[] = {3, 3, 3, 3};
+
+ return std::includes(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib))
+ && !std::includes(std::begin(ia), std::end(ia), std::begin(ic), std::end(ic))
+ ;
+ }
+#endif
+
template <class Iter1, class Iter2>
void
test()
test<const int*, bidirectional_iterator<const int*> >();
test<const int*, random_access_iterator<const int*> >();
test<const int*, const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
// template<InputIterator Iter1, InputIterator Iter2, typename Compare>
// requires Predicate<Compare, Iter1::value_type, Iter2::value_type>
// && Predicate<Compare, Iter2::value_type, Iter1::value_type>
-// bool
+// constexpr bool // constexpr after C++17
// includes(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2, Compare comp);
#include <algorithm>
#include <functional>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ int ib[] = {2, 4};
+ int ic[] = {3, 3, 3, 3};
+
+ auto comp = [](int a, int b) {return a < b; };
+ return std::includes(std::begin(ia), std::end(ia), std::begin(ib), std::end(ib), comp)
+ && !std::includes(std::begin(ia), std::end(ia), std::begin(ic), std::end(ic), comp)
+ ;
+ }
+#endif
+
+
template <class Iter1, class Iter2>
void
test()
test<const int*, bidirectional_iterator<const int*> >();
test<const int*, random_access_iterator<const int*> >();
test<const int*, const int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
// && OutputIterator<OutIter, InIter2::reference>
// && HasLess<InIter2::value_type, InIter1::value_type>
// && HasLess<InIter1::value_type, InIter2::value_type>
-// OutIter
+// constpexr OutIter // constexpr after C++17
// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
// OutIter result);
#include <algorithm>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ const int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int ib[] = {2, 4, 4, 6};
+ int results[std::size(ia)] = {0};
+
+ auto it = std::set_intersection(std::begin(ia), std::end(ia),
+ std::begin(ib), std::end(ib), std::begin(results));
+
+ return std::includes(std::begin(ia), std::end(ia), std::begin(results), it)
+ && std::includes(std::begin(ib), std::end(ib), std::begin(results), it)
+ && std::is_sorted(std::begin(results), it)
+ && std::all_of(it, std::end(results), [](int a) {return a == 0; })
+ ;
+ }
+#endif
+
+
template <class Iter1, class Iter2, class OutIter>
void
test()
test<const int*, const int*, bidirectional_iterator<int*> >();
test<const int*, const int*, random_access_iterator<int*> >();
test<const int*, const int*, int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
// && OutputIterator<OutIter, InIter2::reference>
// && Predicate<Compare, InIter1::value_type, InIter2::value_type>
// && Predicate<Compare, InIter2::value_type, InIter1::value_type>
-// OutIter
+// constpexr OutIter // constexpr after C++17
// set_intersection(InIter1 first1, InIter1 last1, InIter2 first2, InIter2 last2,
// OutIter result, Compare comp);
#include <functional>
#include <cassert>
+#include "test_macros.h"
#include "test_iterators.h"
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ const int ia[] = {1, 2, 2, 3, 3, 3, 4, 4, 4, 4};
+ const int ib[] = {2, 4, 4, 6};
+ int results[std::size(ia)] = {0};
+
+ auto comp = [](int a, int b) {return a < b; };
+ auto it = std::set_intersection(std::begin(ia), std::end(ia),
+ std::begin(ib), std::end(ib), std::begin(results), comp);
+
+ return std::includes(std::begin(ia), std::end(ia), std::begin(results), it)
+ && std::includes(std::begin(ib), std::end(ib), std::begin(results), it)
+ && std::is_sorted(std::begin(results), it, comp)
+ && std::all_of(it, std::end(results), [](int a) {return a == 0; })
+ ;
+ }
+#endif
+
+
template <class Iter1, class Iter2, class OutIter>
void
test()
test<const int*, const int*, bidirectional_iterator<int*> >();
test<const int*, const int*, random_access_iterator<int*> >();
test<const int*, const int*, int*>();
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
-// utilities
+// <utility>
// exchange
+// template<class T, class U=T>
+// constexpr T // constexpr after C++17
+// exchange(T& obj, U&& new_value);
+
#include <utility>
#include <cassert>
#include <string>
+#include "test_macros.h"
+
+#if TEST_STD_VER > 17
+TEST_CONSTEXPR bool test_constexpr() {
+ int v = 12;
+
+ if (12 != std::exchange(v,23) || v != 23)
+ return false;
+
+ if (23 != std::exchange(v,static_cast<short>(67)) || v != 67)
+ return false;
+
+ if (67 != std::exchange<int, short>(v, {}) || v != 0)
+ return false;
+ return true;
+ }
+#endif
+
+
+
int main()
{
{
assert ( std::exchange ( s3, "" ) == s2 );
assert ( s3.size () == 0 );
}
+
+#if TEST_STD_VER > 17
+ static_assert(test_constexpr());
+#endif
}