TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec_container.hpp
Go to the documentation of this file.
1// Time-stamp: <Last changed 2026-02-20 15:54:03 by magnolia>
2/*----------------------------------------------------------------------
3------------------------------------------------------------------------
4Copyright (c) 2020-2026 The Emacs Cat (https://github.com/olddeuteronomy/tec).
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17------------------------------------------------------------------------
18----------------------------------------------------------------------*/
26#pragma once
27
28#include <type_traits>
29
30#include "tec/tec_def.hpp" // IWYU pragma: keep
31
32
33namespace tec {
34
49template<typename T, typename = void>
50struct is_container : std::false_type {};
51
55template<typename T>
56struct is_container<T,
57 std::void_t<
58 decltype(std::declval<T>().begin()),
59 decltype(std::declval<T>().end()),
60 decltype(std::declval<T>().size())
61 >>
62 : std::true_type {};
63
75template<typename T>
76inline constexpr bool is_container_v = is_container<T>::value;
77
78
97template<typename T, typename = void>
98struct is_map : std::false_type {};
99
103template<typename T>
104struct is_map<T,
105 std::void_t<
106 decltype(std::declval<T>().begin()),
107 decltype(std::declval<T>().end()),
108 decltype(std::declval<T>().size()),
109 decltype(std::declval<T>().bucket_count())
110 >>
111 : std::true_type {};
112
125template<typename T>
126inline constexpr bool is_map_v = is_map<T>::value;
127
128} // namespace tec
Trait to detect whether a type behaves like a standard container.
Definition tec_container.hpp:50
Trait to detect associative containers that behave like std::unordered_map / std::unordered_set.
Definition tec_container.hpp:98
constexpr bool is_map_v
Convenience variable template for checking unordered-map-like types.
Definition tec_container.hpp:126
constexpr bool is_container_v
Convenience variable template for checking container-ness.
Definition tec_container.hpp:76
Common definitions and utilities for the tec namespace.