GEOSX
Classes | Namespaces | Macros | Typedefs | Functions | Variables
typeManipulation.hpp File Reference

Contains templates useful for type manipulation. More...

#include "LvArrayConfig.hpp"
#include "Macros.hpp"
#include <camp/camp.hpp>
#include <initializer_list>
#include <utility>

Go to the source code of this file.

Classes

struct  LvArray::typeManipulation::CArray< T, N >
 A wrapper around a compile time c array. More...
 

Namespaces

 LvArray
 The top level namespace.
 
 LvArray::typeManipulation
 Contains templates for manipulating types.
 

Macros

#define IS_VALID_EXPRESSION(NAME, T, ...)
 Macro that expands to a static constexpr bool with one template argument which is true only if the expression is valid. More...
 
#define IS_VALID_EXPRESSION_2(NAME, T, U, ...)
 Macro that expands to a static constexpr bool with two template arguments which is true only if the expression is valid. More...
 
#define HAS_MEMBER_FUNCTION_NO_RTYPE(NAME, ...)   IS_VALID_EXPRESSION( HasMemberFunction_ ## NAME, CLASS, std::declval< CLASS & >().NAME( __VA_ARGS__ ) )
 Macro that expands to a static constexpr bool templated on a type that is only true when the type has a method NAME which takes the given arguments. The name of the boolean variable is HasMemberFunction_ ## NAME. More...
 
#define HAS_MEMBER_TYPE(NAME)   IS_VALID_EXPRESSION( HasMemberType_ ## NAME, CLASS, std::declval< typename CLASS::NAME >() )
 Macro that expands to a static constexpr bool templated on a type that is only true when the type has a nested type (or type alias) called NAME. The name of the boolean variable is HasMemberType_ ## NAME. More...
 
#define HAS_STATIC_MEMBER(NAME)   IS_VALID_EXPRESSION( HasStaticMember_ ## NAME, CLASS, std::enable_if_t< !std::is_member_pointer< decltype( &CLASS::NAME ) >::value, bool >{} )
 Macro that expands to a static constexpr bool templated on a type that is only true when the type has a static member called NAME. The name of the boolean variable is HasStaticMember_ ## NAME. More...
 

Typedefs

template<bool ... BOOLS>
using LvArray::typeManipulation::all_of = camp::concepts::metalib::all_of< BOOLS ... >
 A struct that contains a static constexpr bool value that is true if all of BOOLS are true. More...
 
template<typename ... TYPES>
using LvArray::typeManipulation::all_of_t = camp::concepts::metalib::all_of_t< TYPES ... >
 A struct that contains a static constexpr bool value that is true if all of TYPES::value are true. More...
 
template<typename T >
using LvArray::typeManipulation::ViewType = typename internal::GetViewType< T >::type
 An alias for the view type of T. More...
 
template<typename T >
using LvArray::typeManipulation::ViewTypeConstSizes = typename internal::GetViewTypeConstSizes< T >::type
 An alias for the un-resizable view type of T. More...
 
template<typename T >
using LvArray::typeManipulation::ViewTypeConst = typename internal::GetViewTypeConst< T >::type
 An alias for the const view type of T. More...
 
template<typename T >
using LvArray::typeManipulation::NestedViewType = typename internal::GetNestedViewType< T >::type
 An alias for the nested view type of T. More...
 
template<typename T >
using LvArray::typeManipulation::NestedViewTypeConst = typename internal::GetNestedViewTypeConst< T >::type
 An alias for the nested const view type of T. More...
 

Functions

template<typename F >
constexpr void LvArray::typeManipulation::forEachArg (F &&f)
 The recursive base case where no argument is provided. More...
 
template<typename F , typename ARG , typename ... ARGS>
constexpr void LvArray::typeManipulation::forEachArg (F &&f, ARG &&arg, ARGS &&... args)
 Call the f with arg and then again with each argument in args . More...
 
 LvArray::typeManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE (toView,)
 Defines a template static constexpr bool HasMemberFunction_toView that is true if CLASS has a method toView(). More...
 
 LvArray::typeManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE (toViewConstSizes,)
 Defines a template static constexpr bool HasMemberFunction_toViewConstSizes that is true if CLASS has a method toView(). More...
 
 LvArray::typeManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE (toViewConst,)
 Defines a template static constexpr bool HasMemberFunction_toViewConst that is true if CLASS has a method toViewConst(). More...
 
 LvArray::typeManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE (toNestedView,)
 Defines a template static constexpr bool HasMemberFunction_toNestedView that is true if CLASS has a method toNestedView(). More...
 
 LvArray::typeManipulation::HAS_MEMBER_FUNCTION_NO_RTYPE (toNestedViewConst,)
 Defines a template static constexpr bool HasMemberFunction_toNestedViewConst that is true if CLASS has a method toNestedViewConst(). More...
 
template<camp::idx_t... INDICES>
constexpr camp::idx_t LvArray::typeManipulation::getDimension (camp::idx_seq< INDICES... >)
 
template<camp::idx_t... INDICES>
constexpr camp::idx_t LvArray::typeManipulation::getStrideOneDimension (camp::idx_seq< INDICES... >)
 
template<typename PERMUTATION >
constexpr bool LvArray::typeManipulation::isValidPermutation (PERMUTATION)
 
template<camp::idx_t... INDICES>
constexpr CArray< camp::idx_t, sizeof...(INDICES) > LvArray::typeManipulation::asArray (camp::idx_seq< INDICES... >)
 

Variables

template<template< typename ... > class TEMPLATE, typename TYPE >
constexpr bool LvArray::typeManipulation::is_instantiation_of = false
 Trait to detect if. More...
 
template<template< typename ... > class TEMPLATE, typename ... ARGS>
constexpr bool LvArray::typeManipulation::is_instantiation_of< TEMPLATE, TEMPLATE< ARGS... > > = true
 Trait to detect if. More...
 

Detailed Description

Contains templates useful for type manipulation.

Definition in file typeManipulation.hpp.

Macro Definition Documentation

◆ HAS_MEMBER_FUNCTION_NO_RTYPE

#define HAS_MEMBER_FUNCTION_NO_RTYPE (   NAME,
  ... 
)    IS_VALID_EXPRESSION( HasMemberFunction_ ## NAME, CLASS, std::declval< CLASS & >().NAME( __VA_ARGS__ ) )

Macro that expands to a static constexpr bool templated on a type that is only true when the type has a method NAME which takes the given arguments. The name of the boolean variable is HasMemberFunction_ ## NAME.

Parameters
NAMEThe name of the method to look for.
Note
The remaining macro arguments is the argument list to call the method with.
The class type is available through the name CLASS.

Definition at line 79 of file typeManipulation.hpp.

◆ HAS_MEMBER_TYPE

#define HAS_MEMBER_TYPE (   NAME)    IS_VALID_EXPRESSION( HasMemberType_ ## NAME, CLASS, std::declval< typename CLASS::NAME >() )

Macro that expands to a static constexpr bool templated on a type that is only true when the type has a nested type (or type alias) called NAME. The name of the boolean variable is HasMemberType_ ## NAME.

Parameters
NAMEThe name of the type to look for.

Definition at line 88 of file typeManipulation.hpp.

◆ HAS_STATIC_MEMBER

#define HAS_STATIC_MEMBER (   NAME)    IS_VALID_EXPRESSION( HasStaticMember_ ## NAME, CLASS, std::enable_if_t< !std::is_member_pointer< decltype( &CLASS::NAME ) >::value, bool >{} )

Macro that expands to a static constexpr bool templated on a type that is only true when the type has a static member called NAME. The name of the boolean variable is HasStaticMember_ ## NAME.

Parameters
NAMEThe name of the variable to look for.

Definition at line 97 of file typeManipulation.hpp.

◆ IS_VALID_EXPRESSION

#define IS_VALID_EXPRESSION (   NAME,
  T,
  ... 
)
Value:
template< typename _T > \
struct NAME ## _impl \
{ \
private: \
template< typename T > static constexpr auto test( int )->decltype( __VA_ARGS__, bool() ) \
{ return true; } \
template< typename T > static constexpr auto test( ... )->bool \
{ return false; } \
public: \
static constexpr bool value = test< _T >( 0 ); \
}; \
template< typename T > \
static constexpr bool NAME = NAME ## _impl< T >::value

Macro that expands to a static constexpr bool with one template argument which is true only if the expression is valid.

Parameters
NAMEThe name to give the boolean variable.
TName of the template argument in the expression.
Note
The remaining macro arguments consist of the expresion to check for validity.

Definition at line 33 of file typeManipulation.hpp.

◆ IS_VALID_EXPRESSION_2

#define IS_VALID_EXPRESSION_2 (   NAME,
  T,
  U,
  ... 
)
Value:
template< typename _T, typename _U > \
struct NAME ## _impl \
{ \
private: \
template< typename T, typename U > static constexpr auto test( int )->decltype( __VA_ARGS__, bool() ) \
{ return true; } \
template< typename T, typename U > static constexpr auto test( ... )->bool \
{ return false; } \
public: \
static constexpr bool value = test< _T, _U >( 0 ); \
}; \
template< typename T, typename U > \
static constexpr bool NAME = NAME ## _impl< T, U >::value

Macro that expands to a static constexpr bool with two template arguments which is true only if the expression is valid.

Parameters
NAMEThe name to give the boolean variable.
TName of the first template argument in the expression.
UName of the second template argument in the expression.
Note
The remaining macro arguments consist of the expresion to check for validity.

Definition at line 56 of file typeManipulation.hpp.