Maipa's Standard Library Extension 1.5.6
mstd
Loading...
Searching...
No Matches
containers_utils.hpp
1/*
2 * mstd - Maipa's Standard Library
3 *
4 * Licensed under the BSD 3-Clause License with Attribution Requirement.
5 * See the LICENSE file for details: https://github.com/MAIPA01/mstd/blob/main/LICENSE
6 *
7 * Copyright (c) 2025, Patryk Antosik (MAIPA01)
8 */
9
10#pragma once
11#ifndef _MSTD_CONTAINERS_UTILS_HPP_
12 #define _MSTD_CONTAINERS_UTILS_HPP_
13
14 #include <mstd/config.hpp>
15
17_MSTD_WARNING("this is only available for c++17 and greater!");
18 #else
19
20 #include <mstd/containers_libs.hpp>
21
22 #include <mstd/management_utils.hpp>
23
24namespace mstd {
25 #pragma region IS_ITERATOR
26
27 template<class T, class = void>
28 struct is_iterator : std::false_type {};
29
30 template<class T>
31 struct is_iterator<T, std::void_t<typename std::iterator_traits<T>::iterator_category> > : std::true_type {};
32
33 template<class T>
34 inline _MSTD_CONSTEXPR17 bool is_iterator_v = is_iterator<T>::value;
35
37 template<class T> concept iterator = is_iterator_v<T>;
38 #endif
39 #pragma endregion
40
41 #pragma region IS_ITERATOR_OF
42
43 template<class Iter, class T, class = void>
44 struct is_iterator_of : std::false_type {};
45
46 template<class Iter, class T>
47 struct is_iterator_of<Iter, T,
48 std::void_t<std::enable_if_t<is_iterator_v<Iter> &&
49 (std::is_convertible_v<typename std::iterator_traits<Iter>::value_type, remove_cvref_t<T> > ||
50 std::is_same_v<typename std::iterator_traits<Iter>::value_type, remove_cvref_t<T> >)> > >
51 : std::true_type {};
52
53 template<class Iter, class T>
54 inline _MSTD_CONSTEXPR17 bool is_iterator_of_v = is_iterator_of<Iter, T>::value;
55
57 template<class Iter, class T> concept iterator_of = is_iterator_of_v<Iter, T>;
58 #endif
59 #pragma endregion
60
61 #pragma region IS_SAME_WITHOUT_CVREF
62
63 template<class T, class U>
64 struct is_same_without_cvref : std::is_same<remove_cvref_t<T>, remove_cvref_t<U> > {};
65
66 template<class T>
67 struct is_same_without_cvref<T, T> : std::true_type {};
68
69 template<class T, class U>
70 inline _MSTD_CONSTEXPR17 bool is_same_without_cvref_v = is_same_without_cvref<T, U>::value;
71
73 template<class T, class U> concept same_without_cvref_as = mstd::is_same_without_cvref_v<T, U>;
74 #endif
75 #pragma endregion
76
77} // namespace mstd
78
79 #endif
80#endif
#define _MSTD_HAS_CXX17
Definition config.hpp:45
#define _MSTD_CONSTEXPR17
Definition config.hpp:76
#define _MSTD_HAS_CXX20
Definition config.hpp:52