CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
iter_value.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
14
15#include <iterator>
16#include <type_traits>
17
18namespace CeresEngine::traits {
19
22 template<class T, class = void> struct iter_value {};
23
24 template<class T> struct iter_value<T, std::enable_if_t<has_iterator_traits_value_type_v<remove_cvref_t<T>>>> {
25 using type = typename std::iterator_traits<remove_cvref_t<T>>::value_type;
26 };
27
28 template<class T> struct iter_value<T, std::enable_if_t<!has_iterator_traits_value_type_v<remove_cvref_t<T>> && std::is_pointer_v<T>>> {
29 using type = decltype(*std::declval<std::remove_cv_t<T>>());
30 };
31
32 template<class T>
33 struct iter_value<T, std::enable_if_t<!has_iterator_traits_value_type_v<remove_cvref_t<T>> && !std::is_pointer_v<T> && std::is_array_v<T>>> {
34 using type = std::remove_cv_t<std::remove_extent_t<T>>;
35 };
36
37 template<class T>
38 struct iter_value<T,
39 std::enable_if_t<!has_iterator_traits_value_type_v<remove_cvref_t<T>> && !std::is_pointer_v<T> && !std::is_array_v<T> && std::is_const_v<T>>> {
40 using type = typename iter_value<std::remove_const_t<T>>::type;
41 };
42
43 template<class T>
44 struct iter_value<T,
45 std::enable_if_t<!has_iterator_traits_value_type_v<remove_cvref_t<T>> && !std::is_pointer_v<T> && !std::is_array_v<T> && !std::is_const_v<T> &&
46 has_value_type_v<T>>> {
47 using type = typename T::value_type;
48 };
49
50 template<class T>
51 struct iter_value<T,
52 std::enable_if_t<!has_iterator_traits_value_type_v<remove_cvref_t<T>> && !std::is_pointer_v<T> && !std::is_array_v<T> && !std::is_const_v<T> &&
53 !has_value_type_v<T> && has_element_type_v<T>>> {
54 using type = typename T::element_type;
55 };
56
58 template<class T> using iter_value_t = typename iter_value<T>::type;
59
60} // namespace CeresEngine::traits
Definition Partitioner.hpp:146
typename iter_value< T >::type iter_value_t
A C++17 type trait equivalent to the C++20 iter_value concept.
Definition iter_value.hpp:58
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
A C++17 type trait equivalent to the C++20 iter_value concept.
Definition iter_value.hpp:22