BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
Type Traits

Provides various type traits and their shortcuts. More...

+ Collaboration diagram for Type Traits:

Classes

struct  bio::meta::is_type_specialisation_of< source_t, target_template >
 Determines whether a source_type is a specialisation of another template. More...
 
struct  bio::meta::is_value_specialisation_of< source_t, target_template >
 Provides concept bio::meta::template_specialisation_of<mytype, [...]> for checking the type specialisation of some type with a given template, for example a specialized type_list<float> with the type_list template. More...
 
struct  bio::meta::transfer_template_args_onto< source_template< source_arg_types... >, target_template >
 Extracts a type template's type arguments and specialises another template with them. More...
 
struct  bio::meta::transfer_template_vargs_onto< source_template< source_varg_types... >, target_template >
 Extracts a type template's non-type arguments and specialises another template with them. More...
 
struct  bio::meta::valid_template_spec_or< fallback_t, templ_t, spec_t >
 Exposes templ_t<spec_t...> if that is valid, otherwise fallback_t. More...
 

Concepts

concept  bio::meta::transformation_trait
 Concept for a transformation trait.
 
concept  bio::meta::unary_type_trait
 Concept for a unary traits type.
 

Macros

#define BIOCPP_IS_CONSTEXPR(...)   std::integral_constant<bool, __builtin_constant_p((__VA_ARGS__, 0))>::value
 Returns true if the expression passed to this macro can be evaluated at compile time, false otherwise.
 
#define BIOCPP_IS_SAME(...)   std::is_same_v<__VA_ARGS__>
 A macro that behaves like std::is_same_v, except that it doesn't need to instantiate the template on GCC and Clang.
 

Typedefs

template<typename t >
using default_initialisable_wrap_t = std::conditional_t< std::is_nothrow_default_constructible_v< std::remove_cvref_t< t > > &&constexpr_default_initializable< std::remove_cvref_t< t > >, std::remove_cvref_t< t >, std::type_identity< std::remove_cvref_t< t > > >
 Return t as t if it is noexcept- and constexpr-default-constructible; else wrap it in std::type_identity.
 
using bio::meta::ignore_t = std::remove_cvref_t< decltype(std::ignore)>
 Return the type of std::ignore with const, volatile and references removed (type trait).
 
template<typename t >
using bio::meta::strip_type_identity_t = std::conditional_t< is_type_specialisation_of_v< t, std::type_identity >, transformation_trait_or_t< t, void >, t >
 A transformation trait shortcut that returns the type inside a std::type_identity or the type itself.
 
template<typename source_type , template< typename... > typename target_template>
using bio::meta::transfer_template_args_onto_t = typename transfer_template_args_onto< source_type, target_template >::type
 Shortcut for bio::meta::transfer_template_args_onto (transformation_trait shortcut).
 
template<typename source_type , template< auto... > typename target_template>
using bio::meta::transfer_template_vargs_onto_t = typename transfer_template_vargs_onto< source_type, target_template >::type
 Shortcut for bio::meta::transfer_template_vargs_onto (transformation_trait shortcut).
 
template<typename type_t , typename default_t >
using bio::meta::transformation_trait_or = std::conditional_t< transformation_trait< type_t >, type_t, std::type_identity< default_t > >
 This gives a fallback type if type_t::type is not defined.
 
template<typename type_t , typename default_t >
using bio::meta::transformation_trait_or_t = typename transformation_trait_or< type_t, default_t >::type
 Helper type of bio::meta::transformation_trait_or (transformation_trait shortcut).
 
template<typename fallback_t , template< typename... > typename templ_t, typename... spec_t>
using bio::meta::valid_template_spec_or_t = typename valid_template_spec_or< fallback_t, templ_t, spec_t... >::type
 Helper for bio::meta::valid_template_spec_or (transformation_trait shortcut).
 

Variables

template<typename... t>
constexpr bool bio::meta::always_false = false
 A trait that is always false. Can be used for static_assert(false). DO NOT SPECIALISE!
 
template<typename t >
constexpr bool bio::meta::decays_to_ignore_v = std::is_same_v<std::remove_cvref_t<t>, ignore_t>
 Return whether the input type with const, volatile and references removed is std::ignore's type. (type trait).
 

Detailed Description

Provides various type traits and their shortcuts.

Macro Definition Documentation

◆ BIOCPP_IS_CONSTEXPR

#define BIOCPP_IS_CONSTEXPR (   ...)    std::integral_constant<bool, __builtin_constant_p((__VA_ARGS__, 0))>::value

Returns true if the expression passed to this macro can be evaluated at compile time, false otherwise.

Returns
true or false.

Typedef Documentation

◆ default_initialisable_wrap_t

Return t as t if it is noexcept- and constexpr-default-constructible; else wrap it in std::type_identity.

Template Parameters
tThe type to operate on.

◆ strip_type_identity_t

A transformation trait shortcut that returns the type inside a std::type_identity or the type itself.

Template Parameters
tThe type to operate on.

◆ transfer_template_args_onto_t

template<typename source_type , template< typename... > typename target_template>
using bio::meta::transfer_template_args_onto_t = typedef typename transfer_template_args_onto<source_type, target_template>::type

Shortcut for bio::meta::transfer_template_args_onto (transformation_trait shortcut).

See also
bio::meta::transfer_template_args_onto

◆ transfer_template_vargs_onto_t

template<typename source_type , template< auto... > typename target_template>
using bio::meta::transfer_template_vargs_onto_t = typedef typename transfer_template_vargs_onto<source_type, target_template>::type

Shortcut for bio::meta::transfer_template_vargs_onto (transformation_trait shortcut).

See also
bio::meta::transfer_template_vargs_onto

◆ transformation_trait_or

template<typename type_t , typename default_t >
using bio::meta::transformation_trait_or = typedef std::conditional_t<transformation_trait<type_t>, type_t, std::type_identity<default_t> >

This gives a fallback type if type_t::type is not defined.

Template Parameters
type_tThe type to use if type_t::type is defined.
default_tThe type to use otherwise.
See also
bio::meta::transformation_trait_or_t

Gives type_t back if T::type is a member type, otherwise struct{using type = default_t}.

template <typename T>
struct A;
template <>
struct A<int>
{
using type = int;
};
// A<unsigned>::type is not defined, thus falling back to `void`
static_assert(std::is_same_v<void, bio::meta::transformation_trait_or_t<A<unsigned>, void>>);
// A<int>::type is defined, use A<int>::type
static_assert(std::is_same_v<int, bio::meta::transformation_trait_or_t<A<int>, void>>);
Provides bio::meta::transformation_trait_or.
Attention
This might get removed if one of our used libraries offers the same functionality.

Helper types

bio::meta::transformation_trait_or_t as a shorthand for typename bio::meta::transformation_trait_or::type

◆ transformation_trait_or_t

template<typename type_t , typename default_t >
using bio::meta::transformation_trait_or_t = typedef typename transformation_trait_or<type_t, default_t>::type

Helper type of bio::meta::transformation_trait_or (transformation_trait shortcut).

See also
bio::meta::transformation_trait_or

◆ valid_template_spec_or_t

template<typename fallback_t , template< typename... > typename templ_t, typename... spec_t>
using bio::meta::valid_template_spec_or_t = typedef typename valid_template_spec_or<fallback_t, templ_t, spec_t...>::type

Helper for bio::meta::valid_template_spec_or (transformation_trait shortcut).

See also
bio::meta::valid_template_spec_or
Template Parameters
fallback_tThe fallback type.
templ_tThe type template that should be specialised.
spec_tThe specialisation for the type template.

Variable Documentation

◆ decays_to_ignore_v

template<typename t >
constexpr bool bio::meta::decays_to_ignore_v = std::is_same_v<std::remove_cvref_t<t>, ignore_t>
inlineconstexpr

Return whether the input type with const, volatile and references removed is std::ignore's type. (type trait).

Template Parameters
tThe type to operate on.