Github   Telegram
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
meta.hpp File Reference

Metaprogramming, template variables and concepts. More...

#include <iosfwd>
#include <iterator>
#include <optional>
#include <type_traits>
#include <vector>
#include <userver/utils/void_t.hpp>
+ Include dependency graph for meta.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  meta::NotDetected
 Detection idiom. More...
 

Typedefs

template<typename T , typename U >
using meta::ExpectSame = std::enable_if_t< std::is_same_v< T, U > >
 
template<typename T >
using meta::MapKeyType = DetectedType< impl::KeyType, T >
 
template<typename T >
using meta::MapValueType = DetectedType< impl::MappedType, T >
 
template<typename T >
using meta::RangeValueType = DetectedType< impl::RangeValueType, T >
 

Functions

template<typename T >
auto meta::Inserter (T &container)
 Returns default inserter for a container. More...
 

Variables

template<template< typename... > typename Template, typename... Args>
constexpr bool meta::kIsInstantiationOf
 
template<typename T >
constexpr bool meta::kIsVector = kIsInstantiationOf<std::vector, T>
 
template<typename T >
constexpr bool meta::kIsRange = kIsDetected<impl::IsRange, T>
 
template<typename T >
constexpr bool meta::kIsMap
 
template<typename T >
constexpr bool meta::kIsRecursiveRange
 
template<typename T >
constexpr bool meta::kIsOptional = kIsInstantiationOf<std::optional, T>
 
template<typename T >
constexpr bool meta::kIsCharacter
 
template<typename T >
constexpr bool meta::kIsInteger
 
template<typename T >
constexpr bool meta::kIsOstreamWritable
 
template<typename T , typename U = T>
constexpr bool meta::kIsEqualityComparable
 
template<typename T >
constexpr bool meta::kIsStdHashable
 
template<typename T >
constexpr bool meta::kIsSizable = kIsDetected<impl::IsSizable, T>
 Check if std::size is applicable to container. More...
 
template<typename T >
constexpr bool meta::kIsReservable = kIsDetected<impl::ReserveResult, T>
 Check if a container has reserve More...
 
template<typename T >
constexpr bool meta::kIsPushBackable = kIsDetected<impl::PushBackResult, T>
 Check if a container has 'push_back'. More...
 
template<typename T >
constexpr bool meta::kIsFixedSizeContainer
 Check if a container has fixed size (e.g. std::array) More...
 
template<template< typename... > typename Trait, typename... Args>
using meta::DetectedType = typename impl::Detector< NotDetected, void, Trait, Args... >::type
 
template<typename Default , template< typename... > typename Trait, typename... Args>
using meta::DetectedOr = typename impl::Detector< Default, void, Trait, Args... >::type
 
template<template< typename... > typename Trait, typename... Args>
constexpr bool meta::kIsDetected
 Checks whether a trait is correct for the given template args. More...
 

Detailed Description

Metaprogramming, template variables and concepts.

Definition in file meta.hpp.

Typedef Documentation

◆ DetectedOr

template<typename Default , template< typename... > typename Trait, typename... Args>
using meta::DetectedOr = typedef typename impl::Detector<Default, void, Trait, Args...>::type

Produces the result type of a trait, or Default if it's incorrect for the given template args

Definition at line 62 of file meta.hpp.

◆ DetectedType

template<template< typename... > typename Trait, typename... Args>
using meta::DetectedType = typedef typename impl::Detector<NotDetected, void, Trait, Args...>::type

Produces the result type of a trait, or NotDetected if it's incorrect for the given template args

Definition at line 55 of file meta.hpp.

◆ ExpectSame

template<typename T , typename U >
using meta::ExpectSame = typedef std::enable_if_t<std::is_same_v<T, U> >

Definition at line 66 of file meta.hpp.

◆ MapKeyType

template<typename T >
using meta::MapKeyType = typedef DetectedType<impl::KeyType, T>

Definition at line 156 of file meta.hpp.

◆ MapValueType

template<typename T >
using meta::MapValueType = typedef DetectedType<impl::MappedType, T>

Definition at line 159 of file meta.hpp.

◆ RangeValueType

template<typename T >
using meta::RangeValueType = typedef DetectedType<impl::RangeValueType, T>

Definition at line 162 of file meta.hpp.

Function Documentation

◆ Inserter()

template<typename T >
auto meta::Inserter ( T &  container)

Returns default inserter for a container.

Definition at line 215 of file meta.hpp.

Variable Documentation

◆ kIsCharacter

template<typename T >
constexpr bool meta::kIsCharacter
inlineconstexpr
Initial value:
=
std::is_same_v<T, char> || std::is_same_v<T, wchar_t> ||
std::is_same_v<T, char16_t> || std::is_same_v<T, char32_t>

Returns true if the type is a fundamental character type. signed char and unsigned char are not character types.

Definition at line 174 of file meta.hpp.

◆ kIsDetected

template<template< typename... > typename Trait, typename... Args>
constexpr bool meta::kIsDetected
inlineconstexpr
Initial value:
= !std::is_same_v<
typename impl::Detector<NotDetected, void, Trait, Args...>::type,
NotDetected>

Checks whether a trait is correct for the given template args.

Definition at line 48 of file meta.hpp.

◆ kIsEqualityComparable

template<typename T , typename U = T>
constexpr bool meta::kIsEqualityComparable
inlineconstexpr
Initial value:
=
kIsDetected<impl::IsEqualityComparable, T, U>

Definition at line 189 of file meta.hpp.

◆ kIsFixedSizeContainer

template<typename T >
constexpr bool meta::kIsFixedSizeContainer
inlineconstexpr
Initial value:
=
impl::IsFixedSizeContainer<T>::value

Check if a container has fixed size (e.g. std::array)

Definition at line 210 of file meta.hpp.

◆ kIsInstantiationOf

template<template< typename... > typename Template, typename... Args>
constexpr bool meta::kIsInstantiationOf
inlineconstexpr
Initial value:
=
impl::IsInstantiationOf<Template, Args...>::value

Definition at line 142 of file meta.hpp.

◆ kIsInteger

template<typename T >
constexpr bool meta::kIsInteger
inlineconstexpr
Initial value:
=
std::is_integral_v<T> && !kIsCharacter<T> && !std::is_same_v<T, bool>

Returns true if the type is a true integer type (not *char* or bool) signed char and unsigned char are integer types

Definition at line 181 of file meta.hpp.

◆ kIsMap

template<typename T >
constexpr bool meta::kIsMap
inlineconstexpr
Initial value:
= kIsDetected<impl::IsRange, T>&&
kIsDetected<impl::KeyType, T>&& kIsDetected<impl::MappedType, T>

Definition at line 152 of file meta.hpp.

◆ kIsOptional

template<typename T >
constexpr bool meta::kIsOptional = kIsInstantiationOf<std::optional, T>
inlineconstexpr

Definition at line 169 of file meta.hpp.

◆ kIsOstreamWritable

template<typename T >
constexpr bool meta::kIsOstreamWritable
inlineconstexpr
Initial value:
=
kIsDetected<impl::IsOstreamWritable, T>

Definition at line 185 of file meta.hpp.

◆ kIsPushBackable

template<typename T >
constexpr bool meta::kIsPushBackable = kIsDetected<impl::PushBackResult, T>
inlineconstexpr

Check if a container has 'push_back'.

Definition at line 206 of file meta.hpp.

◆ kIsRange

template<typename T >
constexpr bool meta::kIsRange = kIsDetected<impl::IsRange, T>
inlineconstexpr

Definition at line 149 of file meta.hpp.

◆ kIsRecursiveRange

template<typename T >
constexpr bool meta::kIsRecursiveRange
inlineconstexpr
Initial value:
=
std::is_same_v<DetectedType<RangeValueType, T>, T>

Definition at line 165 of file meta.hpp.

◆ kIsReservable

template<typename T >
constexpr bool meta::kIsReservable = kIsDetected<impl::ReserveResult, T>
inlineconstexpr

Check if a container has reserve

Definition at line 202 of file meta.hpp.

◆ kIsSizable

template<typename T >
constexpr bool meta::kIsSizable = kIsDetected<impl::IsSizable, T>
inlineconstexpr

Check if std::size is applicable to container.

Definition at line 198 of file meta.hpp.

◆ kIsStdHashable

template<typename T >
constexpr bool meta::kIsStdHashable
inlineconstexpr
Initial value:
=
kIsDetected<impl::IsStdHashable, T>&& kIsEqualityComparable<T>

Definition at line 193 of file meta.hpp.

◆ kIsVector

template<typename T >
constexpr bool meta::kIsVector = kIsInstantiationOf<std::vector, T>
inlineconstexpr

Definition at line 146 of file meta.hpp.