MADARA  3.4.1
StlHelper.h File Reference
#include <type_traits>

Go to the source code of this file.

Classes

struct  madara::utility::type< T >
 helper type for specifying template type parameters using a function argument instead of inside explicit "<...>". More...
 

Namespaces

 madara
 Copyright(c) 2020 Galois.
 
 madara::utility
 Provides utility functions and classes for common tasks and needs.
 

Macros

#define MADARA_AUTORET_FUNC(NAME, ARGS, ...)
 
#define MADARA_AUTORET_REF_FUNC(NAME, ARGS, ...)
 
#define MADARA_MAKE_SUPPORT_TEST(name, var, expr)
 Macro which generates feature testing traits, to allow enabling features based on what a given type supports. More...
 
#define MADARA_MAKE_VAL_SUPPORT_TEST(name, var, expr)
 Macro which generates feature testing traits, to allow enabling features based on what a given type supports. More...
 

Typedefs

template<typename T >
using madara::utility::decay_ = typename std::decay< T >::type
 Less verbose synonym for std::decay. More...
 
template<bool Pred, typename T = void>
using madara::utility::enable_if_ = typename std::enable_if< Pred, T >::type
 Less verbose synonym for std::enable_if. More...
 

Functions

template<typename T >
std::unique_ptr< decay_< T > > madara::utility::into_unique (T &&val)
 Converts a typed value into a unique_ptr of a decayed type. More...
 
template<typename Func , typename Arg0 >
auto madara::utility::invoke_ (Func func, Arg0 &&arg0) -> decltype(std::forward< Arg0 >(arg0).*func)
 
template<typename Func , typename Arg0 , typename... Args>
auto madara::utility::invoke_ (Func func, Arg0 &&arg0, Args &&... args) -> decltype((std::forward< Arg0 >(arg0).*func)(std::forward< Args >(args)...))
 
template<typename Func , typename... Args>
auto madara::utility::invoke_ (Func func, Args &&... args) -> decltype(func(std::forward< Args >(args)...))
 
template<typename T >
constexpr bool madara::utility::is_arithmetic ()
 Less verbose equivalent for std::is_arithmetic. More...
 
template<typename Base , typename Derived >
constexpr bool madara::utility::is_base_of ()
 Less verbose equivalent for std::is_base_of. More...
 
template<typename Base , typename Derived >
constexpr bool madara::utility::is_base_of_decayed ()
 Composition of std::is_base_of and std::decay. More...
 
template<typename From , typename To >
constexpr bool madara::utility::is_convertible ()
 Less verbose equivalent for std::is_convertible. More...
 
template<typename T >
constexpr bool madara::utility::is_enum ()
 Less verbose equivalent for std::is_enum. More...
 
template<typename T >
constexpr bool madara::utility::is_floating_point ()
 Less verbose equivalent for std::is_floating_point. More...
 
template<typename T >
constexpr bool madara::utility::is_int_numeric ()
 Is T arithmetic or an enum? More...
 
template<typename T >
constexpr bool madara::utility::is_integral ()
 Less verbose equivalent for std::is_integral. More...
 
template<typename T >
constexpr bool madara::utility::is_numeric ()
 Is T arithmetic or an enum? More...
 
template<typename T , typename U >
constexpr bool madara::utility::is_same ()
 Less verbose equivalent for std::is_same. More...
 
template<typename T , typename U >
constexpr bool madara::utility::is_same_decayed ()
 Composition of std::is_same and std::decay. More...
 
template<typename T , typename... Args>
std::unique_ptr< T > madara::utility::mk_unique (Args &&... args)
 Creates a unique_ptr for the templated type. More...
 

Macro Definition Documentation

◆ MADARA_AUTORET_FUNC

#define MADARA_AUTORET_FUNC (   NAME,
  ARGS,
  ... 
)
Value:
inline auto NAME \
ARGS->::madara::utility::core::decay_<decltype(__VA_ARGS__)> \
{ \
return (__VA_ARGS__); \
}

Definition at line 178 of file StlHelper.h.

◆ MADARA_AUTORET_REF_FUNC

#define MADARA_AUTORET_REF_FUNC (   NAME,
  ARGS,
  ... 
)
Value:
inline auto NAME ARGS->decltype(__VA_ARGS__) \
{ \
return (__VA_ARGS__); \
}

Definition at line 185 of file StlHelper.h.

◆ MADARA_MAKE_SUPPORT_TEST

#define MADARA_MAKE_SUPPORT_TEST (   name,
  var,
  expr 
)
Value:
template<typename T> \
struct supports_##name##_impl \
{ \
template<typename U> \
static auto test(U* var) -> decltype((expr), std::true_type()); \
template<typename U> \
static auto test(...) -> std::false_type; \
using type = decltype(test<T>(0)); \
}; \
template<typename T> \
struct supports_##name : supports_##name##_impl<T>::type \
{ \
}

Macro which generates feature testing traits, to allow enabling features based on what a given type supports.

The tests provide ::value member which is true if the given expr can compile correctly with the given type; false otherwise

var is a pointer to the type being tested

Definition at line 20 of file StlHelper.h.

◆ MADARA_MAKE_VAL_SUPPORT_TEST

#define MADARA_MAKE_VAL_SUPPORT_TEST (   name,
  var,
  expr 
)
Value:
template<typename T> \
struct supports_##name##_impl \
{ \
template<typename U> \
static auto test(U var) -> decltype((expr), std::true_type()); \
template<typename U> \
static auto test(...) -> std::false_type; \
using type = decltype(test<T>(std::declval<T>())); \
}; \
template<typename T> \
struct supports_##name : supports_##name##_impl<T>::type \
{ \
}

Macro which generates feature testing traits, to allow enabling features based on what a given type supports.

The tests provide value member which is true if the given expr can compile correctly with the given type; false otherwise

var is a value of the type being tested

Definition at line 43 of file StlHelper.h.