Skip to content

Commit 3420530

Browse files
committed
Define our own derived_from as std not available on all platforms
1 parent 5b81a37 commit 3420530

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

include/boost/math/concepts/concepts.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,22 @@ 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+
template <typename Derived, typename Base>
179+
concept derived_from = std::is_base_of_v<Base, Derived> &&
180+
std::is_convertible_v<const volatile Derived*, const volatile Base*>;
181+
178182
template <typename T>
179-
concept forward_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::forward_iterator_tag>;
183+
concept forward_iterator = derived_from<typename std::iterator_traits<T>::iterator_category, std::forward_iterator_tag>;
180184

181185
template <typename T>
182-
concept bidirectional_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::bidirectional_iterator_tag>;
186+
concept bidirectional_iterator = derived_from<typename std::iterator_traits<T>::iterator_category, std::bidirectional_iterator_tag>;
183187

184188
template <typename T>
185-
concept random_access_iterator = std::derived_from<typename std::iterator_traits<T>::iterator_category, std::random_access_iterator_tag>;
189+
concept random_access_iterator = derived_from<typename std::iterator_traits<T>::iterator_category, std::random_access_iterator_tag>;
186190

187191
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>;
192+
concept output_iterator = derived_from<typename std::iterator_traits<I>::iterator_category, std::input_iterator_tag> &&
193+
derived_from<typename std::iterator_traits<T>::iterator_category, std::output_iterator_tag>;
190194

191195
template <typename T>
192196
concept is_container = detail::has_begin_v<T> &&

0 commit comments

Comments
 (0)