Loading...
Searching...
No Matches
Dune::Simd::Overloads::ADLTag< i, bool > Struct Template Reference
Common » Vectorization » Abstraction Developer's Interface

Tag used to force late-binding lookup in Dune::Simd::Overloads. More...

Inheritance diagram for Dune::Simd::Overloads::ADLTag< i, bool >:

## Detailed Description

template<unsigned i, bool = true>
struct Dune::Simd::Overloads::ADLTag< i, bool >

Tag used to force late-binding lookup in Dune::Simd::Overloads.

This tag is used by functions in `Dune::Simd` to make argument-dependent lookups (ADL) for functions in `Dune::Simd::Overloads`. The property of ADL that is used here is that it binds the names of functions late, i.e. at the time of instantiation, while all other lookups bind early, i.e. at the time when the function call is parsed. Using late binding enables a function `foo()` to find a functions `Overloads::foo()` that has been declared only after `foo()` itself has been defined:

template<class V>
void foo(V v)
{
foo(Overloads::ADLTag<6>{}, v);
}
struct MyType {};
namespace Overloads {
void foo(ADLTag<4>, MyType v);
}
Dune::Simd::Overloads::ADLTag
Tag used to force late-binding lookup in Dune::Simd::Overloads.
Definition base.hh:182

Note
  It is generally an error to declare a function with an ADLTag argument outside of namespace Simd::Overloads. An exception would be an abstraction implementation that declares all its implementation functions in its own implementation namespace, and then pulls them into the namespace Overloads by way of `using`.

ADLTag<i> derives from ADLTag<i-1>. Thus it is possible to prioritize overloads by choosing an appropriate `i`. The following values for `i` are predefined:

- i==0,1: these are reserved for the defaults.
- i==2,3: these are reserved for the implementation for standard types.
- i==5,6: these should normally be used by other implementations

The lower priority should be used by default. The higher priority can be used by an implementation to resolve ambiguities, e.g. between an overload with a by-value argument and an overload with an lvalue-reference argument.

The following priorities should not normally be used. However, they may sometimes be necessary:

- `i==4`: override standard implementation, but prefer other implementations
- `i==7`: try to override other implementations

`i==7` is the highest supported priority.

The second (bool) template argument is to make writing abstraction implementations that use SFINAE to remove (some of) their functions from the overload set more concise. `ADLTag<i,false>` is not defined, so instead of

std::enable_if_t<cond, ADLTag<4> >

you may write the equivalent

ADLTag<4, cond>

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

- base.hh