dune-common
2.6-git
|
Standard library features backported from newer C++ versions or technical specifications and DUNE-specific utilities. More...
![]() |
Files | |
file | keywords.hh |
Definitions of several macros that conditionally make C++ syntax available. | |
file | proxymemberaccess.hh |
infrastructure for supporting operator->() on both references and proxies | |
Namespaces | |
Dune::Std | |
Namespace for features backported from new C++ standards. | |
Classes | |
class | Dune::IteratorRange< Iterator > |
Simple range between a begin and an end iterator. More... | |
struct | Dune::Std::is_callable< D, R > |
Traits class to check if function is callable. More... | |
struct | Dune::Std::is_callable< F(Args...), R > |
Traits class to check if function is callable. More... | |
struct | Dune::Std::is_invocable< F, Args > |
Traits class to check if function is invocable. More... | |
struct | Dune::Std::is_invocable_r< R, F, Args > |
Traits class to check if function is invocable and the return type is compatible. More... | |
struct | Dune::Std::nonesuch |
Type representing a lookup failure by std::detected_or and friends. More... | |
struct | Dune::Std::conjunction< B > |
forms the logical conjunction of the type traits B... More... | |
struct | Dune::Std::disjunction< B > |
forms the logical disjunction of the type traits B... More... | |
struct | Dune::Empty |
Just an empty class. More... | |
struct | Dune::IsInteroperable< T1, T2 > |
Checks whether two types are interoperable. More... | |
struct | Dune::EnableIfInterOperable< T1, T2, Type > |
Enable typedef if two types are interoperable. More... | |
struct | Dune::AlwaysFalse< T > |
template which always yields a false value More... | |
struct | Dune::AlwaysTrue< T > |
template which always yields a true value More... | |
struct | Dune::IsNumber< T > |
Whether this type acts as a scalar in the context of (hierarchically blocked) containers. More... | |
struct | Dune::has_nan< T > |
Whether this type has a value of NaN. More... | |
struct | Dune::is_indexable< T, I > |
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed with an index of type I. More... | |
struct | Dune::is_range< T, typename > |
typetrait to check that a class has begin() and end() members More... | |
struct | Dune::IsTuple< T > |
Check if T is a std::tuple<...> More... | |
struct | Dune::IsTupleOrDerived< T > |
Check if T derived from a std::tuple<...> More... | |
struct | Dune::IsIntegralConstant< T > |
Check if T is an std::integral_constant<I, i> More... | |
struct | Dune::SizeOf< T > |
Compute size of variadic type list. More... | |
struct | Dune::IntegerSequenceEntry< IntegerSequence, index > |
Get entry of std::integer_sequence. More... | |
class | Dune::Std::to_false_type< T > |
template mapping a type to std::false_type More... | |
class | Dune::Std::to_true_type< T > |
template mapping a type to std::true_type More... | |
Macros | |
#define | DUNE_ASSERT_AND_RETURN(C, X) (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X |
Asserts a condition and return on success in constexpr context. More... | |
#define | DUNE_DEPRECATED |
Mark some entity as deprecated. More... | |
#define | DUNE_DEPRECATED_MSG(text) DUNE_DEPRECATED |
Mark some entity as deprecated. More... | |
#define | DUNE_NO_DEPRECATED_BEGIN ... |
Ignore deprecation warnings (start) More... | |
#define | DUNE_NO_DEPRECATED_END ... |
Ignore deprecation warnings (end) More... | |
#define | DUNE_UNUSED |
A macro for marking variables that the compiler mistakenly flags as unused, which sometimes happens due to templates. More... | |
#define | DUNE_UNUSED_PARAMETER(parm) static_cast<void>(parm) |
A macro to mark intentionally unused function parameters with. More... | |
Typedefs | |
template<bool value> | |
using | Dune::Std::bool_constant = std::integral_constant< bool, value > |
A template alias for std::integral_constant<bool, value> More... | |
template<typename Default , template< typename... > class Op, typename... Args> | |
using | Dune::Std::detected_or = Impl::detector< Default, void, Op, Args... > |
Detects whether Op<Args...> is valid and makes the result available. More... | |
template<template< typename... > class Op, typename... Args> | |
using | Dune::Std::is_detected = typename detected_or< nonesuch, Op, Args... >::value_t |
Detects whether Op<Args...> is valid. More... | |
template<template< typename... > class Op, typename... Args> | |
using | Dune::Std::detected_t = typename detected_or< nonesuch, Op, Args... >::type |
Returns Op<Args...> if that is valid; otherwise returns nonesuch. More... | |
template<typename Default , template< typename... > class Op, typename... Args> | |
using | Dune::Std::detected_or_t = typename detected_or< Default, Op, Args... >::type |
Returns Op<Args...> if that is valid; otherwise returns the fallback type Default . More... | |
template<typename Expected , template< typename... > class Op, typename... Args> | |
using | Dune::Std::is_detected_exact = std::is_same< Expected, detected_t< Op, Args... > > |
Checks whether Op<Args...> is Expected without causing an error if Op<Args...> is invalid. More... | |
template<typename Target , template< typename... > class Op, typename... Args> | |
using | Dune::Std::is_detected_convertible = std::is_convertible< Target, detected_t< Op, Args... > > |
Checks whether Op<Args...> is convertible to Target without causing an error if Op<Args...> is invalid. More... | |
template<class... Types> | |
using | Dune::void_t = typename Impl::voider< Types... >::type |
Is void for all valid input types (see N3911). The workhorse for C++11 SFINAE-techniques. More... | |
template<class Type > | |
using | Dune::field_t = typename FieldTraits< Type >::field_type |
Convenient access to FieldTraits<Type>::field_type. More... | |
template<class Type > | |
using | Dune::real_t = typename FieldTraits< Type >::real_type |
Convenient access to FieldTraits<Type>::real_type. More... | |
Functions | |
template<typename T , std::size_t n> | |
std::array< T, n > | Dune::fill_array (const T &t) |
Create an array and fill it with copies of the provided value. More... | |
template<class... F> | |
auto | Dune::overload (F &&... f) |
Create an overload set. More... | |
template<class... F> | |
auto | Dune::orderedOverload (F &&... f) |
Create an ordered overload set. More... | |
template<typename T > | |
pointer_or_proxy_holder | Dune::handle_proxy_member_access (T &&t) |
Transparent support for providing member access to both lvalues and rvalues (temporary proxies). More... | |
template<class F , class ArgTuple > | |
decltype(auto) | Dune::Std::apply (F &&f, ArgTuple &&args) |
Apply function with arguments given as tuple. More... | |
template<typename... Args> | |
std::array< typename std::common_type< Args... >::type, sizeof...(Args)> | Dune::Std::make_array (const Args &... args) |
Create and initialize an array. More... | |
template<typename T , typename... Args> | |
Impl::MakeUniqueHelper< T >::NonArrayUniquePtr | Dune::Std::make_unique (Args &&... args) |
Implementation of std::make_unique to be introduced in C++14. More... | |
template<typename T > | |
Impl::MakeUniqueHelper< T >::UnknownBoundArrayUniquePtr | Dune::Std::make_unique (size_t n) |
Implementation of std::make_unique to be introduced in C++14. More... | |
template<class T , T... t, std::size_t index> | |
constexpr auto | Dune::integerSequenceEntry (std::integer_sequence< T, t... >, std::integral_constant< std::size_t, index > i) |
Get entry of std::integer_sequence. More... | |
Variables | |
template<template< typename... > class Op, typename... Args> | |
constexpr bool | Dune::Std::is_detected_v = is_detected<Op,Args...>::value |
Detects whether Op<Args...> is valid and makes the result available as a value. More... | |
template<typename Expected , template< typename... > class Op, typename... Args> | |
constexpr bool | Dune::Std::is_detected_exact_v = is_detected_exact<Expected,Op,Args...>::value |
Convenient access to the result value of is_detected_exact. More... | |
template<typename Target , template< typename... > class Op, typename... Args> | |
constexpr bool | Dune::Std::is_detected_convertible_v = is_detected_convertible<Target,Op,Args...>::value |
Convenient access to the result value of is_detected_convertible. More... | |
Standard library features backported from newer C++ versions or technical specifications and DUNE-specific utilities.
#define DUNE_ASSERT_AND_RETURN | ( | C, | |
X | |||
) | (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X |
Asserts a condition and return on success in constexpr context.
The macro DUNE_ASSERT_AND_RETURN can be used as expression in the return statement of a constexpr function to have assert() and constexpr at the same time. It first uses assert for the condition given by the first argument and then returns the value of the second argument.
#define DUNE_DEPRECATED |
Mark some entity as deprecated.
This is a preprocessor define which can be used to mark functions, typedefs, enums and other stuff deprecated. If something is marked deprecated, users are advised to migrate to the new interface, since it will probably be removed in the next release of Dune.
DUNE_DEPRECATED currently works with g++ and clang++. For other compilers it will be defined empty. This way the user will not get any deprecation warning, but at least his code still compiles (well, until the next Dune release, that is).
Here are some examples how to mark different stuff deprecated:
#define DUNE_DEPRECATED_MSG | ( | text | ) | DUNE_DEPRECATED |
Mark some entity as deprecated.
This is a preprocessor define which can be used to mark functions, typedefs, enums and other stuff deprecated and to also specify a hint what replaces the given functionality. If something is marked deprecated, users are advised to migrate to the new interface, since it will probably be removed in the next release of Dune.
DUNE_DEPRECATED_MSG currently works only for compilers which support the attribute attribute((deprecated("message")). For other compilers it will be defined empty. This way the user will not get any deprecation warning, but at least his code still compiles (well, until the next Dune release, that is).
Here are some examples how to mark different stuff deprecated:
#define DUNE_NO_DEPRECATED_BEGIN ... |
Ignore deprecation warnings (start)
This macro can be used together with DUNE_NO_DEPRECATED_END
to mark a block in which deprecation warnings are ignored. This can be useful for implementations of deprecated methods that call other deprecated methods or for testing deprecated methods in the testsuite.
DUNE_NO_DEPRECATED_END
#define DUNE_NO_DEPRECATED_END ... |
Ignore deprecation warnings (end)
DUNE_NO_DEPRECATED_BEGIN
#define DUNE_UNUSED |
A macro for marking variables that the compiler mistakenly flags as unused, which sometimes happens due to templates.
#define DUNE_UNUSED_PARAMETER | ( | parm | ) | static_cast<void>(parm) |
A macro to mark intentionally unused function parameters with.
using Dune::Std::bool_constant = typedef std::integral_constant<bool, value> |
A template alias for std::integral_constant<bool, value>
value | Boolean value to encode as std::integral_constant<bool, value> |
using Dune::Std::detected_or = typedef Impl::detector<Default,void,Op,Args...> |
Detects whether Op<Args...>
is valid and makes the result available.
This alias template is an alias for an unspecified class type with two nested typedefs
value_t
and type
. It can be used to detect whether the meta function call Op<Args...>
is valid and access the result of the call by inspecting the returned type, which is defined as follows:
Op<Args...>
can be instantiated, value_t
is an alias for std::true_type
and type
is an alias for Op<Args...>
.Op<Args...>
is invalid, value_t
is an alias for std::false_type
and type
is an alias for Default
.This can be used to safely extract a nested typedef
from a type T
that might not define the typedef
:
using Dune::Std::detected_or_t = typedef typename detected_or<Default,Op,Args...>::type |
Returns Op<Args...>
if that is valid; otherwise returns the fallback type Default
.
This alias template can be used to instantiate Op<Args...>
in a context that is not SFINAE-safe by appropriately wrapping the instantiation and automatically falling back to Default
if instantiation fails.
using Dune::Std::detected_t = typedef typename detected_or<nonesuch,Op,Args...>::type |
Returns Op<Args...>
if that is valid; otherwise returns nonesuch.
This alias template can be used to instantiate Op<Args...>
in a context that is not SFINAE-safe by appropriately wrapping the instantiation. If instantiation fails, the marker type nonesuch is returned instead.
using Dune::field_t = typedef typename FieldTraits<Type>::field_type |
Convenient access to FieldTraits<Type>::field_type.
using Dune::Std::is_detected = typedef typename detected_or<nonesuch,Op,Args...>::value_t |
Detects whether Op<Args...>
is valid.
This alias template checks whether Op<Args...>
can be instantiated. It is equivalent to typename detected_or<nonesuch,Op,Args...>::value_t
.
using Dune::Std::is_detected_convertible = typedef std::is_convertible<Target,detected_t<Op,Args...> > |
Checks whether Op<Args...>
is convertible to Target
without causing an error if Op<Args...>
is invalid.
using Dune::Std::is_detected_exact = typedef std::is_same<Expected,detected_t<Op,Args...> > |
Checks whether Op<Args...>
is Expected
without causing an error if Op<Args...>
is invalid.
using Dune::real_t = typedef typename FieldTraits<Type>::real_type |
Convenient access to FieldTraits<Type>::real_type.
using Dune::void_t = typedef typename Impl::voider<Types...>::type |
Is void for all valid input types (see N3911). The workhorse for C++11 SFINAE-techniques.
decltype(auto) Dune::Std::apply | ( | F && | f, |
ArgTuple && | args | ||
) |
Apply function with arguments given as tuple.
f | A callable object |
args | Tuple of arguments |
This will call the function with arguments generated by unpacking the tuple.
std::array<T,n> Dune::fill_array | ( | const T & | t | ) |
Create an array and fill it with copies of the provided value.
pointer_or_proxy_holder Dune::handle_proxy_member_access | ( | T && | t | ) |
Transparent support for providing member access to both lvalues and rvalues (temporary proxies).
If an iterator facade (like entity iterators) wants to allow the embedded implementation to return either an (internally stored) reference or a temporary object and expose these two behaviors to enable performance optimizations, operator->() needs special handling: If the implementation returns a reference, operator->() in the facade can simply return the address of the referenced object, but if the returned object is a temporary, we need to capture and store it in a helper object to make sure it outlives the member access. This function transparently supports both variants. It should be used like this:
constexpr auto Dune::integerSequenceEntry | ( | std::integer_sequence< T, t... > | , |
std::integral_constant< std::size_t, index > | i | ||
) |
Get entry of std::integer_sequence.
seq | An object of type std::integer_sequence<...> |
i | Index |
std::array<typename std::common_type<Args...>::type, sizeof...(Args)> Dune::Std::make_array | ( | const Args &... | args | ) |
Create and initialize an array.
|
delete |
Implementation of std::make_unique to be introduced in C++14.
T | Nonarray type of object to be constructed |
...Args | Parameter types for constructor of T |
args | Arguments to be passed to constructor of T |
This fallback implementation using perfect forwarding as proposed by Herb Sutter in http://herbsutter.com/gotw/_102/
Impl::MakeUniqueHelper<T>::UnknownBoundArrayUniquePtr Dune::Std::make_unique | ( | size_t | n | ) |
Implementation of std::make_unique to be introduced in C++14.
T | Array type of unknown bound |
n | Size of array to allocate |
auto Dune::orderedOverload | ( | F &&... | f | ) |
Create an ordered overload set.
F | List of function object types |
f | List of function objects |
This returns an object that contains all operator() implementations of the passed functions. All those are available when calling operator() of the returned object.
In contrast to overload() these overloads are ordered in the sense that the first matching overload for the given arguments is selected and later ones are ignored. Hence such a call is never ambiguous.
Notice that the passed function objects are stored by value and must be copy-constructible.
auto Dune::overload | ( | F &&... | f | ) |
Create an overload set.
F | List of function object types |
f | List of function objects |
This returns an object that contains all operator() implementations of the passed functions. All those are available when calling operator() of the returned object.
The returned object derives from those implementations such that it contains all operator() implementations in its overload set. When calling operator() this will select the best overload. If multiple overload are equally good this will lead to ambiguity.
Notice that the passed function objects are stored by value and must be copy-constructible.
constexpr bool Dune::Std::is_detected_convertible_v = is_detected_convertible<Target,Op,Args...>::value |
Convenient access to the result value of is_detected_convertible.
constexpr bool Dune::Std::is_detected_exact_v = is_detected_exact<Expected,Op,Args...>::value |
Convenient access to the result value of is_detected_exact.
constexpr bool Dune::Std::is_detected_v = is_detected<Op,Args...>::value |
Detects whether Op<Args...>
is valid and makes the result available as a value.
This constexpr variable checks whether Op<Args...>
can be instantiated. It is equivalent to is_detected<Op,Args...>::value
.