Dune Core Modules (2.10.0)

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. More...
 

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
}
Adapter of a hybrid functor that maintains results hybrid.
Definition: hybridutilities.hh:418
constexpr index_constant< 1 > _1
Compile time index with value 1.
Definition: indices.hh:55
constexpr index_constant< 2 > _2
Compile time index with value 2.
Definition: indices.hh:58
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

The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)