BRICKS
Small, useful blocks of code, to build bigger things.
Loading...
Searching...
No Matches
type_traits.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iterator>
4#include <type_traits>
5
6namespace bricks {
7
8namespace detail {
9
10template <typename T, typename U, typename = void>
11struct has_find : std::false_type {
12};
13
14template <typename T, typename U>
15struct has_find<T, U, std::void_t<decltype(std::declval<T>().find(std::declval<U>()))>>
16 : std::true_type {
17};
18
19template <typename T, typename = void>
20struct is_iterator : std::false_type {
21};
22
23template <typename T>
24struct is_iterator<T, std::void_t<typename std::iterator_traits<T>::iterator_category>>
25 : std::true_type {
26};
27
28} // namespace detail
29
33template <class>
34inline constexpr bool always_false_v = false;
35
45template <typename T, typename U>
46struct has_find : detail::has_find<T, U>::type {
47};
48
56template <class T, typename U>
57inline constexpr bool has_find_v = has_find<T, U>::value;
58
67template <typename T>
68struct is_iterator : detail::is_iterator<T>::type {
69};
70
79template <typename T>
80inline constexpr bool is_iterator_v = is_iterator<T>::value;
81
82} // namespace bricks
Definition algorithm.hpp:12
constexpr bool is_iterator_v
Helper variable template to check if a type is an iterator.
Definition type_traits.hpp:80
constexpr bool always_false_v
Helper variable template for static assertions.
Definition type_traits.hpp:34
Checks if a type has a find method taking a specific type.
Definition type_traits.hpp:46
Checks if a type is an iterator.
Definition type_traits.hpp:68