sparrow 0.3.0
Loading...
Searching...
No Matches
mp_utils.hpp File Reference
#include <concepts>
#include <cstdint>
#include <iterator>
#include <memory>
#include <ranges>
#include <span>
#include <tuple>
#include <type_traits>
Include dependency graph for mp_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sparrow::mpl::dependent_false< T >
 Workaround to replace static_assert(false) in template code. More...
 
struct  sparrow::mpl::is_type_instance_of< L, U >
 
struct  sparrow::mpl::is_type_instance_of< L< T... >, U >
 
struct  sparrow::mpl::typelist< T >
 A sequence of types, used for meta-programming operations. More...
 
struct  sparrow::mpl::impl::rename_impl< From< T... >, To >
 
struct  sparrow::mpl::predicate::same_as< T >
 Compile-time type predicate: true if the evaluated type is the same as T. More...
 
struct  sparrow::mpl::ct_type_predicate_to_callable< P >
 
struct  sparrow::mpl::impl::transform_impl< F, L >
 
struct  sparrow::mpl::impl::transform_impl< F, L< T... > >
 
struct  sparrow::mpl::impl::transform_impl< F, L1< T1... >, L2< T2... > >
 
struct  sparrow::mpl::add_const_lvalue_reference< T >
 
struct  sparrow::mpl::constify< T, is_const >
 
struct  sparrow::mpl::constify< T &, is_const >
 
struct  sparrow::mpl::excludes_copy_and_move_ctor< CLS, ARGS >
 
struct  sparrow::mpl::excludes_copy_and_move_ctor< CLS >
 
struct  sparrow::mpl::excludes_copy_and_move_ctor< CLS, T >
 

Namespaces

namespace  sparrow
 
namespace  sparrow::mpl
 
namespace  sparrow::mpl::impl
 
namespace  sparrow::mpl::predicate
 

Concepts

concept  sparrow::mpl::any_typelist
 Matches any type which is an instance of typelist.
 
concept  sparrow::mpl::type_wrapper
 Matches template types which can be used as type-wrappers for evaluation in type-predicates.
 
concept  sparrow::mpl::ct_type_predicate
 Matches template types that can be evaluated at compile-time similarly to std::true/false_type This makes possible to use predicates provided by the standard.
 
concept  sparrow::mpl::callable_type_predicate
 Matches types whose instance can be called with an object representing a type to evaluate it.
 
concept  sparrow::mpl::constant_iterator
 Represents a constant iterator.
 
concept  sparrow::mpl::constant_range
 The constant_range concept is a refinement of range for which ranges::begin returns a constant iterator.
 
concept  sparrow::mpl::bool_convertible_range
 Matches range types whose elements are convertible to bool.
 
concept  sparrow::mpl::boolean_like
 Matches types that can be convertible to and assignable from bool.
 
concept  sparrow::mpl::convertible_ranges
 Matches range types From whose elements are convertible to elements of range type To.
 
concept  sparrow::mpl::unique_ptr
 
concept  sparrow::mpl::unique_ptr_or_derived
 
concept  sparrow::mpl::shared_ptr
 
concept  sparrow::mpl::shared_ptr_or_derived
 
concept  sparrow::mpl::smart_ptr
 
concept  sparrow::mpl::smart_ptr_and_derived
 
concept  sparrow::mpl::testable
 
concept  sparrow::mpl::T_matches_qualifier_if_Y_is
 
concept  sparrow::mpl::iterator_of_type
 Concept to check if an iterator is of a specific type.
 
concept  sparrow::mpl::char_like
 
concept  sparrow::mpl::std_array
 
concept  sparrow::mpl::fixed_size_span
 

Typedefs

template<class TypeList, class... Us>
using sparrow::mpl::append_t = decltype(append(TypeList{}, Us{}...))
 Appends one or more types or typelist to a given TypeList.
 
template<class From, template< class... > class To>
using sparrow::mpl::rename = typename impl::rename_impl<From, To>::type
 Changes the type of the list to the given type/ Example: static_assert(std::same_as<rename<typelist<int, float>, std::variant>, std::variant<int, float>>)
 
template<template< class > class F, class... L>
using sparrow::mpl::transform = typename impl::transform_impl<F, L...>::type
 Applies the metafunction F to each tuple of elements in the typelists and returns the corresponding list Example: transform<std::add_pointer_t, typelist<int, float> gives typelist<int*, float*> transform<std::is_same, typelist<int, float>, typelist<int, int>> gives typelist<std::is_same<int, int>, std::is_same<float, int>>
 
template<class T>
using sparrow::mpl::add_const_lvalue_reference_t = typename add_const_lvalue_reference<T>::type
 
template<class T, bool is_const>
using sparrow::mpl::constify_t = typename constify<T, is_const>::type
 
template<class T>
using sparrow::mpl::iter_const_reference_t = std::common_reference_t<const std::iter_value_t<T>&&, std::iter_reference_t<T>>
 Computes the const reference type of T.
 

Functions

template<class... Ts, class... Us>
requires (!is_type_instance_of_v<Us, typelist> && ...)
consteval auto sparrow::mpl::append (typelist< Ts... >, Us...)
 Appends the given types to a typelist.
 
template<class... Ts, class... Us>
consteval auto sparrow::mpl::append (typelist< Ts... >, typelist< Us... >)
 Appends two typelists together.
 
template<class... T>
constexpr std::size_t sparrow::mpl::size (typelist< T... >={})
 
template<class T, template< class > class P>
requires ct_type_predicate<P, T>
consteval bool sparrow::mpl::evaluate (P< T >)
 Evaluates the provided compile-time template class predicate P given a type T, if P is of a similar shape to std::true/false_type.
 
template<class T, callable_type_predicate< T > P>
consteval bool sparrow::mpl::evaluate (P predicate)
 Evaluates the provided compile-time template class predicate P given a type T, if P's instance is callable given a value type wrapper of T.
 
template<template< class > class P>
consteval auto sparrow::mpl::as_predicate ()
 
template<class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (callable_type_predicate<Predicate, T> && ...)
consteval bool sparrow::mpl::any_of (L< T... >, Predicate predicate={})
 Checks that at least one type in the provided list of is making the provide predicate return true.
 
template<template< class > class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (ct_type_predicate<Predicate, T> && ...)
consteval bool sparrow::mpl::any_of (L< T... > list)
 Checks that at least one type in the provided list of is making the provide predicate return true.
 
template<class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (callable_type_predicate<Predicate, T> && ...)
consteval bool sparrow::mpl::all_of (L< T... >, Predicate predicate)
 Checks that every type in the provided list of is making the provide predicate return true.
 
template<template< class > class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (ct_type_predicate<Predicate, T> && ...)
consteval bool sparrow::mpl::all_of (L< T... > list)
 Checks that every type in the provided list of is making the provide predicate return true.
 
template<class V, any_typelist L>
consteval bool sparrow::mpl::contains (L list)
 
template<class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (callable_type_predicate<Predicate, T> && ...)
consteval std::size_t sparrow::mpl::find_if (L< T... >, Predicate predicate)
 
template<template< class > class Predicate, template< class... > class L, class... T>
requires any_typelist<L<T...>> and (ct_type_predicate<Predicate, T> && ...)
consteval std::size_t sparrow::mpl::find_if (L< T... > list)
 
template<class TypeToFind, any_typelist L>
consteval std::size_t sparrow::mpl::find (L list)
 
void sparrow::mpl::unreachable ()
 Invokes undefined behavior.
 

Variables

template<class T, template< class... > class U>
constexpr bool sparrow::mpl::is_type_instance_of_v = is_type_instance_of<T, U>::value
 true if T is a concrete type template instanciation of U which is a type template.
 
template<class CLS, class... ARGS>
constexpr bool sparrow::mpl::excludes_copy_and_move_ctor_v = excludes_copy_and_move_ctor<CLS, ARGS...>::value