yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.2
MetaUtils Namespace Reference

Namespaces

namespace  detail
 Traits detection. Check's whether expression is valid for type T.
 
namespace  operatorTraits
 

Classes

struct  conjunction
 Logical conjuction implementation. More...
 
struct  conjunction< B1 >
 
struct  conjunction< B1, Bn... >
 
struct  nonesuch
 

Typedefs

template<typename T , template< typename ... > class U>
using is_instance = is_instance_impl< std::decay_t< T >, U >
 Detects if type T is an instance of template U.
 
template<template< class... > class Op, class... Args>
using is_detected = typename detail::detector< nonesuch, void, Op, Args... >::value_t
 
template<template< class... > class Op, class... Args>
using detected_t = typename detail::detector< nonesuch, void, Op, Args... >::type
 
template<class Default , template< class... > class Op, class... Args>
using detected_or = detail::detector< Default, void, Op, Args... >
 
template<class Expected , template< class... > class Op, class... Args>
using is_detected_exact = std::is_same< Expected, detected_t< Op, Args... > >
 

Functions

template<class Func , std::size_t... Is>
constexpr void staticForImpl (Func &&f, std::index_sequence< Is... >)
 
template<size_t N, class Func >
constexpr void staticFor (Func &&f)
 Used to apply functor on tuple. Calls lambda with integral constant, which can be used to query tuple elements via std::get<I>(), and thus iterate over tuple.
 
template<typename T , template< class U > class Concept>
constexpr bool checkConcept ()
 checks whether if T satisfies user defined Concept
 
int check (bool pred, const char *funcName)
 
template<size_t I, typename... Ts>
auto removeTupleElement (const std::tuple< Ts... > &tup)
 

Variables

template<template< class... > class Op, class... Args>
constexpr bool is_detected_v = is_detected<Op, Args...>::value
 

Detailed Description

Todo:
Merge with Traits.h

Typedef Documentation

◆ detected_or

template<class Default , template< class... > class Op, class... Args>
using MetaUtils::detected_or = typedef detail::detector<Default, void, Op, Args...>

Definition at line 97 of file MetaUtils.h.

◆ detected_t

template<template< class... > class Op, class... Args>
using MetaUtils::detected_t = typedef typename detail::detector<nonesuch, void, Op, Args...>::type

Definition at line 94 of file MetaUtils.h.

◆ is_detected

template<template< class... > class Op, class... Args>
using MetaUtils::is_detected = typedef typename detail::detector<nonesuch, void, Op, Args...>::value_t

Definition at line 91 of file MetaUtils.h.

◆ is_detected_exact

template<class Expected , template< class... > class Op, class... Args>
using MetaUtils::is_detected_exact = typedef std::is_same<Expected, detected_t<Op, Args...> >

Definition at line 100 of file MetaUtils.h.

◆ is_instance

template<typename T , template< typename ... > class U>
using MetaUtils::is_instance = typedef is_instance_impl<std::decay_t<T>, U>

Detects if type T is an instance of template U.

Definition at line 88 of file MetaUtils.h.

Function Documentation

◆ check()

int MetaUtils::check ( bool  pred,
const char *  funcName 
)
inline

Definition at line 114 of file MetaUtils.h.

114 {
115 if (pred == false)
116 std::clog << funcName << " FAILED\n";
117 return (int)(pred ? EXIT_SUCCESS : EXIT_FAILURE);
118 }

◆ checkConcept()

template<typename T , template< class U > class Concept>
constexpr bool MetaUtils::checkConcept ( )
constexpr

checks whether if T satisfies user defined Concept

Note
Concept check should appear inside body of type's member function or outside of type, since otherwise type is considered incomplete.

Definition at line 110 of file MetaUtils.h.

110 {
111 return Concept<T>::checkResult::value;
112 }

◆ removeTupleElement()

template<size_t I, typename... Ts>
auto MetaUtils::removeTupleElement ( const std::tuple< Ts... > &  tup)

Definition at line 147 of file MetaUtils.h.

147 {
148 return _removeTupleElement<I>(tup, std::make_index_sequence<sizeof...(Ts)>{});
149 }

◆ staticFor()

template<size_t N, class Func >
constexpr void MetaUtils::staticFor ( Func &&  f)
constexpr

Used to apply functor on tuple. Calls lambda with integral constant, which can be used to query tuple elements via std::get<I>(), and thus iterate over tuple.

To use, create lambda which captures every necessary variable by referenrece (or value) and has (auto I) parameter. Then use I inside lambda to call templated functions.

Definition at line 34 of file MetaUtils.h.

34 {
35 staticForImpl(std::forward<Func>(f),
36 std::make_index_sequence<N>{});
37 }
constexpr void staticForImpl(Func &&f, std::index_sequence< Is... >)
Definition MetaUtils.h:13

References staticForImpl().

Referenced by YODA::containsNan().

◆ staticForImpl()

template<class Func , std::size_t... Is>
constexpr void MetaUtils::staticForImpl ( Func &&  f,
std::index_sequence< Is... >   
)
constexpr

Definition at line 13 of file MetaUtils.h.

14 {
15 // Use C++17 fold expressions to apply Func f
16 // to all Is... in sequence
17 //
18 // Won't work on empty tuple (Binning is not intended to work with 0 dimensions).
19 //
20 // std::integral_constant used to encode value into type, otherwise it's not
21 // possible to use Is inside functor as consant expression
22 // (std::get<Is> etc. won't work)
23
24 ((void)f(std::integral_constant<std::size_t, Is>()), ...);
25 }

Referenced by staticFor().

Variable Documentation

◆ is_detected_v

template<template< class... > class Op, class... Args>
constexpr bool MetaUtils::is_detected_v = is_detected<Op, Args...>::value
constexpr

Definition at line 103 of file MetaUtils.h.