Skip to content

Commit

Permalink
Move any_of concept
Browse files Browse the repository at this point in the history
This avoids an issue with circular includes
  • Loading branch information
DeveloperPaul123 committed Aug 3, 2023
1 parent 0f3978d commit 1549638
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 31 deletions.
31 changes: 3 additions & 28 deletions include/flux/core/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,10 @@ template <std::integral To>
inline constexpr auto checked_cast = detail::checked_cast_fn<To>{};

namespace detail {
template <bool FirstValue, class First, class... Rest>
struct disjunction_t { // handle true trait or last trait
using type = First;
};


template <class False, class Next, class... Rest>
struct disjunction_t<false, False, Next,
Rest...> { // first trait is false, try the next trait
using type = typename disjunction_t<Next::value, Next, Rest...>::type;
};

template <class... Traits>
struct disjunction : std::false_type {}; // If _Traits is empty, false_type

template <class First, class... Rest>
struct disjunction<First, Rest...>
: disjunction_t<First::value, First, Rest...>::type {
// the first true trait in _Traits, or the last trait if none are true
};

template <class... Traits>
inline constexpr bool disjunction_v = disjunction<Traits...>::value;

// VARIABLE TEMPLATE _Is_any_of_v
template <class T, class... Types>
inline constexpr bool is_any_of = disjunction_v<std::is_same<T, Types>...>;
;
template <typename T, typename... U>
concept any_of = (std::same_as<T, U> || ...);
} // namespace detail

} // namespace flux

#endif
4 changes: 1 addition & 3 deletions include/flux/op/split_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
#define FLUX_STRING_SPLIT_HPP_INCLUDED

#include <flux/op/split.hpp>
#include <flux/core/utils.hpp>

#include <string_view>

namespace flux {

namespace detail {

template <typename T, typename... U>
concept any_of = (std::same_as<T, U> || ...);

template <typename C>
concept character = any_of<C, char, wchar_t, char8_t, char16_t, char32_t>;

Expand Down

0 comments on commit 1549638

Please sign in to comment.