userver: userver/utils/meta.hpp File Reference
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
meta.hpp File Reference

Detailed Description

Metaprogramming, template variables and concepts.

Definition in file meta.hpp.

Go to the source code of this file.

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

Typedefs

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.
 

Variables

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
 Returns true if T is an ordered or unordered map or multimap.
 
template<typename T>
constexpr bool meta::kIsUniqueMap
 Returns true if T is a map (but not a multimap!)
 
template<typename T>
constexpr bool meta::kIsRecursiveRange = std::is_same_v<DetectedType<impl::RangeValueType, T>, T>
 
template<typename T>
constexpr bool meta::kIsIterator = impl::IsIterator<T>::value
 
template<typename T>
constexpr bool meta::kIsOptional = kIsInstantiationOf<std::optional, T>
 
template<typename T>
constexpr bool meta::kIsOstreamWritable = std::is_same_v<DetectedType<impl::OstreamWriteResult, T>, std::ostream&>
 
template<typename T, typename U = T>
constexpr bool meta::kIsEqualityComparable = std::is_same_v<DetectedType<impl::EqualityComparisonResult, T, U>, bool>
 
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.
 
template<typename T>
constexpr bool meta::kIsReservable = kIsDetected<impl::ReserveResult, T>
 Check if a container has reserve
 
template<typename T>
constexpr bool meta::kIsPushBackable = kIsDetected<impl::PushBackResult, T>
 Check if a container has 'push_back'.
 
template<typename T>
constexpr bool meta::kIsFixedSizeContainer = impl::IsFixedSizeContainer<T>::value
 Check if a container has fixed size (e.g. std::array)
 

Typedef Documentation

◆ MapKeyType

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

Definition at line 106 of file meta.hpp.

◆ MapValueType

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

Definition at line 109 of file meta.hpp.

◆ RangeValueType

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

Definition at line 112 of file meta.hpp.

Function Documentation

◆ Inserter()

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

Returns default inserter for a container.

Definition at line 151 of file meta.hpp.

Variable Documentation

◆ kIsEqualityComparable

template<typename T, typename U = T>
bool meta::kIsEqualityComparable = std::is_same_v<DetectedType<impl::EqualityComparisonResult, T, U>, bool>
inlineconstexpr

Definition at line 127 of file meta.hpp.

◆ kIsFixedSizeContainer

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

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

Definition at line 147 of file meta.hpp.

◆ kIsIterator

template<typename T>
bool meta::kIsIterator = impl::IsIterator<T>::value
inlineconstexpr

Definition at line 118 of file meta.hpp.

◆ kIsMap

template<typename T>
bool meta::kIsMap
inlineconstexpr
Initial value:

Returns true if T is an ordered or unordered map or multimap.

Definition at line 96 of file meta.hpp.

◆ kIsOptional

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

Definition at line 121 of file meta.hpp.

◆ kIsOstreamWritable

template<typename T>
bool meta::kIsOstreamWritable = std::is_same_v<DetectedType<impl::OstreamWriteResult, T>, std::ostream&>
inlineconstexpr

Definition at line 124 of file meta.hpp.

◆ kIsPushBackable

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

Check if a container has 'push_back'.

Definition at line 143 of file meta.hpp.

◆ kIsRange

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

Definition at line 92 of file meta.hpp.

◆ kIsRecursiveRange

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

Definition at line 115 of file meta.hpp.

◆ kIsReservable

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

Check if a container has reserve

Definition at line 139 of file meta.hpp.

◆ kIsSizable

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

Check if std::size is applicable to container.

Definition at line 135 of file meta.hpp.

◆ kIsStdHashable

template<typename T>
bool meta::kIsStdHashable
inlineconstexpr
Initial value:
=
std::is_same_v<DetectedType<impl::StdHashResult, T>, std::size_t> && kIsEqualityComparable<T>

Definition at line 130 of file meta.hpp.

◆ kIsUniqueMap

template<typename T>
bool meta::kIsUniqueMap
inlineconstexpr
Initial value:
impl::SubscriptOperatorResult,
T>

Returns true if T is a map (but not a multimap!)

Definition at line 101 of file meta.hpp.

◆ kIsVector

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

Definition at line 89 of file meta.hpp.