ComPPare 1.0.0
Loading...
Searching...
No Matches
comppare::outspec< Value, Policy > Struct Template Reference

Specification struct for pairing an output type with an error policy. More...

Detailed Description

template<typename Value, typename Policy = void>
struct comppare::outspec< Value, Policy >

Specification struct for pairing an output type with an error policy.

The outspec struct represents an output type together with its error policy. Inside the framework, every argument passed to OutputContext is normalized into some form of outspec<Value, Policy>.

How OutputContext normalizes output types

  • Raw types If the user passes a bare type (e.g. double), it is automatically wrapped as outspec<double, void>. The void signals that the framework should deduce the policy via AutoPolicy_t<double>. This case is handled by the specialization outspec<Value, void>.
  • Explicit policies If the user passes set_policy<T, P>, it is an alias for outspec<T, P>. Within OutputContext, this is first normalized as outspec<outspec<T, P>, void>, in the same way raw types are normalized. This case is handled by the specialization outspec<outspec<Value, Policy>, void>.

Why the double-wrapping

Consider a mix of raw types and explicit policies in OutputContext:

OutputContext class template to hold output parameters and manage implementations.
Definition comppare.hpp:292
Specification struct for pairing an output type with an error policy.
Definition comppare.hpp:192

Here:

  • T1 is normalized as outspec<T1, void> (auto policy).
  • outspec<T0, P0> is normalized as outspec<outspec<T0, P0>, void>.

All arguments are first treated as outspec<..., void>. Without this mechanism, users would have to explicitly write:

which is less convenient, since most users do not need custom policies.

Template Parameters
ValueThe output value type.
PolicyThe error policy type. Defaults to void for auto-selection.

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