Skip to content

Commit 5b81a37

Browse files
committed
Remove libc++ workaround
1 parent 6bd07ec commit 5b81a37

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

include/boost/math/concepts/concepts.hpp

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,30 +175,18 @@ concept arbitrary_numerical_type = arbitrary_real_or_complex_type<T> ||
175175
template <typename T>
176176
concept policy = boost::math::policies::is_policy<T>::value;
177177

178-
// Workaround for LIBCPP versions that have <concepts> but have not implemented concepts in <iterator>
179-
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 13000
180-
181-
template <typename T>
182-
concept forward_iterator = std::is_same_v<typename std::iterator_traits<T>::iterator_category(), std::forward_iterator_tag>;
183-
184-
template <typename T>
185-
concept bidirectional_iterator = std::is_same_v<typename std::iterator_traits<T>::iterator_category(), std::bidirectional_iterator_tag>;
186-
187178
template <typename T>
188-
concept random_access_iterator = std::is_same_v<typename std::iterator_traits<T>::iterator_category(), std::random_access_iterator_tag>;
189-
190-
#else
179+
concept forward_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::forward_iterator_tag>;
191180

192181
template <typename T>
193-
concept forward_iterator = std::forward_iterator<T>;
182+
concept bidirectional_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::bidirectional_iterator_tag>;
194183

195184
template <typename T>
196-
concept bidirectional_iterator = std::bidirectional_iterator<T>;
185+
concept random_access_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::random_access_iterator_tag>;
197186

198-
template <typename T>
199-
concept random_access_iterator = std::random_access_iterator<T>;
200-
201-
#endif
187+
template <typename I, typename T>
188+
concept output_iterator = std::derived_from<typename std::iterator_traits<I>::iterator_category, std::input_iterator_tag> &&
189+
std::derived_from<typename std::iterator_traits<T>::iterator_category, std::output_iterator_tag>;
202190

203191
template <typename T>
204192
concept is_container = detail::has_begin_v<T> &&
@@ -230,25 +218,19 @@ concept random_access_container = is_container<T> &&
230218
#define BOOST_MATH_ARBITRARY_COMPLEX boost::math::concepts::arbitrary_complex_type
231219
#define BOOST_MATH_ARBITRARY_REAL_OR_COMPLEX boost::math::concepts::arbitrary_real_or_complex_type
232220
#define BOOST_MATH_ARBITRARY_NUMERICAL boost::math::concepts::arbitrary_numerical_type
221+
233222
#define BOOST_MATH_POLICY boost::math::concepts::policy
223+
234224
#define BOOST_MATH_CONTAINER boost::math::concepts::is_container
235225
#define BOOST_MATH_RANDOM_ACCESS_CONTAINER boost::math::concepts::random_access_container
236-
#define BOOST_MATH_REQUIRES(X, T) requires X<T>
237-
238-
// Workaround for LIBCPP versions that have <concepts> but have not implemented concepts in <iterator>
239-
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 13000
240226

241227
#define BOOST_MATH_FORWARD_ITER boost::math::concepts::forward_iterator
242228
#define BOOST_MATH_BIDIRECTIONAL_ITER boost::math::concepts::bidirectional_iterator
243229
#define BOOST_MATH_RANDOM_ACCESS_ITER boost::math::concepts::random_access_iterator
230+
#define BOOST_MATH_OUTPUT_ITER(I, T) boost::math::concepts::output_iterator<I, T>
231+
#define BOOST_MATH_REQUIRES_ITER(X) requires X
244232

245-
#else
246-
247-
#define BOOST_MATH_FORWARD_ITER std::forward_iterator
248-
#define BOOST_MATH_BIDIRECTIONAL_ITER std::bidirectional_iterator
249-
#define BOOST_MATH_RANDOM_ACCESS_ITER std::random_access_iterator
250-
251-
#endif // Workaround for LIBCPP
233+
#define BOOST_MATH_REQUIRES(X, T) requires X<T>
252234

253235
#ifdef BOOST_MATH_EXEC_COMPATIBLE
254236
#include <execution>
@@ -365,6 +347,14 @@ concept execution_policy = std::is_execution_policy_v<std::remove_cvref_t<T>>;
365347
# define BOOST_MATH_RANDOM_ACCESS_ITER typename
366348
#endif
367349

350+
#ifndef BOOST_MATH_OUTPUT_ITER
351+
# define BOOST_MATH_OUTPUT_ITER(I, T)
352+
#endif
353+
354+
#ifndef BOOST_MATH_REQUIRES_ITER
355+
# define BOOST_MATH_REQUIRES_ITER(X)
356+
#endif
357+
368358
#ifndef BOOST_MATH_CONTAINER
369359
# define BOOST_MATH_CONTAINER typename
370360
#endif

include/boost/math/statistics/univariate_statistics.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ inline auto interquartile_range(RandomAccessContainer & v)
598598
}
599599

600600
template<BOOST_MATH_EXECUTION_POLICY ExecutionPolicy, BOOST_MATH_FORWARD_ITER ForwardIterator, class OutputIterator>
601+
BOOST_MATH_REQUIRES_ITER(BOOST_MATH_OUTPUT_ITER(ForwardIterator, OutputIterator))
601602
inline OutputIterator mode(ExecutionPolicy&& exec, ForwardIterator first, ForwardIterator last, OutputIterator output)
602603
{
603604
if(!std::is_sorted(exec, first, last))
@@ -616,12 +617,14 @@ inline OutputIterator mode(ExecutionPolicy&& exec, ForwardIterator first, Forwar
616617
}
617618

618619
template<BOOST_MATH_EXECUTION_POLICY ExecutionPolicy, BOOST_MATH_CONTAINER Container, class OutputIterator>
620+
BOOST_MATH_REQUIRES_ITER(BOOST_MATH_OUTPUT_ITER(typename Container::iterator, OutputIterator))
619621
inline OutputIterator mode(ExecutionPolicy&& exec, Container & v, OutputIterator output)
620622
{
621623
return mode(exec, std::begin(v), std::end(v), output);
622624
}
623625

624626
template<BOOST_MATH_FORWARD_ITER ForwardIterator, class OutputIterator>
627+
BOOST_MATH_REQUIRES_ITER(BOOST_MATH_OUTPUT_ITER(ForwardIterator, OutputIterator))
625628
inline OutputIterator mode(ForwardIterator first, ForwardIterator last, OutputIterator output)
626629
{
627630
return mode(std::execution::seq, first, last, output);
@@ -636,6 +639,7 @@ template<BOOST_MATH_CONTAINER Container, class OutputIterator, std::enable_if_t<
636639
&& !std::is_convertible_v<std::execution::unsequenced_policy, Container>
637640
#endif
638641
, bool> = true>
642+
BOOST_MATH_REQUIRES_ITER(BOOST_MATH_OUTPUT_ITER(typename Container::iterator, OutputIterator))
639643
inline OutputIterator mode(Container & v, OutputIterator output)
640644
{
641645
return mode(std::execution::seq, std::begin(v), std::end(v), output);

0 commit comments

Comments
 (0)