dune-common 2.10
Loading...
Searching...
No Matches
Dune::Hybrid::HybridFunctor< Functor > Class Template Reference

Adapter of a hybrid functor that maintains results hybrid. More...

#include <dune/common/hybridutilities.hh>

Public Member Functions

template<class... Args>
constexpr decltype(auto) operator() (const Args &... args) const
 Adapter of a hybrid functor that keeps results hybrid.
 

Detailed Description

template<class Functor>
class Dune::Hybrid::HybridFunctor< Functor >

Adapter of a hybrid functor that maintains results hybrid.

This adapter will return an integral constant if all of the arguments are integral constants. That's helpful to maintain the hybrid nature of a variable after a transformation. For example, applying an operator + between two integral constants will promote the result to its underlying type (e.g. std::size_t). That's inconventient since the value of the result is not encoded in the type anymore, thus, losing its hybrid attribute (maybe still being constexpr).

using namespace Dune::Indices;
{ // non-hybrid transformation!
auto i = 1 + 2; // -> 3
auto j = 1 + _2; // -> 3
auto k = _1 + _2; // -> 3
// depending of the context, `k` may or may not be constexpr
}
{ // hybrid transformation!
auto j = plus( 1, 2); // -> 3
auto j = plus( 1, _2); // -> 3
auto k = plus(_1, _2); // -> Dune::Indices::_3
// independent of the context, `k` encodes its value in the type system
}
constexpr auto plus
Function object for performing addition.
Definition hybridutilities.hh:528
Namespace with predefined compile time indices for the range [0,19].
Definition indices.hh:50
Adapter of a hybrid functor that maintains results hybrid.
Definition hybridutilities.hh:418

The documentation for this class was generated from the following file: