TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
Loading...
Searching...
No Matches
tec_container.hpp File Reference

Generic container and map traits. More...

#include <type_traits>
#include "tec/tec_def.hpp"

Go to the source code of this file.

Classes

struct  tec::is_container< T, typename >
 Trait to detect whether a type behaves like a standard container. More...
 
struct  tec::is_container< T, std::void_t< decltype(std::declval< T >().begin()), decltype(std::declval< T >().end()), decltype(std::declval< T >().size()) > >
 Specialization that activates when T has begin(), end(), and size(). More...
 
struct  tec::is_map< T, typename >
 Trait to detect associative containers that behave like std::unordered_map / std::unordered_set. More...
 
struct  tec::is_map< T, std::void_t< decltype(std::declval< T >().begin()), decltype(std::declval< T >().end()), decltype(std::declval< T >().size()), decltype(std::declval< T >().bucket_count()) > >
 Specialization that activates when T has the unordered-map-like interface. More...
 

Variables

template<typename T >
constexpr bool tec::is_container_v = is_container<T>::value
 Convenience variable template for checking container-ness.
 
template<typename T >
constexpr bool tec::is_map_v = is_map<T>::value
 Convenience variable template for checking unordered-map-like types.
 

Detailed Description

Generic container and map traits.

Author
The Emacs Cat
Date
2025-11-29

Variable Documentation

◆ is_container_v

template<typename T >
constexpr bool tec::is_container_v = is_container<T>::value
inlineconstexpr

Convenience variable template for checking container-ness.

Usage:

static_assert(tec::is_container_v<std::vector<int>>);
static_assert(!tec::is_container_v<int>);
Template Parameters
TType to test

◆ is_map_v

template<typename T >
constexpr bool tec::is_map_v = is_map<T>::value
inlineconstexpr

Convenience variable template for checking unordered-map-like types.

Usage:

static_assert(tec::is_map_v<std::unordered_map<std::string, int>>);
static_assert(!tec::is_map_v<std::map<std::string, int>>);
static_assert(!tec::is_map_v<std::vector<int>>);
Template Parameters
TType to test