-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCArray.h
More file actions
37 lines (29 loc) · 1.22 KB
/
Copy pathCArray.h
File metadata and controls
37 lines (29 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once
#include <concepts>
#include <cstdio>
#include <ranges>
#include <tuple>
#include <type_traits>
#include <utility>
#include "CEnumerable.h"
namespace Platform::Abstractions {
namespace Internal {
template <typename TSelf, typename... TItems>
consteval bool CArrayHelpFunction() {
constexpr bool member_indexator = requires(TSelf self, std::size_t index) { {self[index]} /*-> std::same_as<typename Enumerable<TSelf>::ItemReference>*/; };
if constexpr (sizeof...(TItems) == 1) {
using SelfItem = typename Enumerable<TSelf>::Item;
using RequiredItem = std::remove_reference_t<decltype(std::get<0>(std::declval<std::tuple<TItems...>>()))>;
return member_indexator && std::ranges::random_access_range<TSelf> && std::same_as<SelfItem, RequiredItem>;
}
if constexpr (sizeof...(TItems) == 0) {
return member_indexator && std::ranges::random_access_range<TSelf>;
}
return false;
}
} // namespace Internal
template <typename TSelf, typename... TItems>
concept CArray = CEnumerable<TSelf> && Internal::CArrayHelpFunction<TSelf, TItems...>();
template <CArray TSelf>
struct Array : Enumerable<TSelf> {};
} // namespace Platform::Abstractions