One

template<typename TElementType, typename TSfinae = void>
struct One

Adapter for the identity element of the given type.

Specialisations of this struct should be stateless trivially default constructible with two call operator of signatures:

  1. TElementType operator()(size_t n) const (possibly noexcept, inline and/or constexpr also) returning a multiplicative identity element for the category TElementType and with Degree<TElementType>()(x) equal to the parameter n. For example, if TElementType is a type of n x n matrices, then this should return the n x n identity matrix.

  2. TElementType operator()(T const&) const (possibly noexcept, inline and/or constexpr also). This could be implemented as:

    TElementType operator()(TElementType const& x) const noexcept {
      return this->operator()(Degree<TElementType>()(x));
    }
    

Used by:

Example

template <typename T>
struct One<
    T,
    typename std::enable_if<std::is_base_of<PTransf16, T>::value>::type> {
  T operator()(size_t = 0) const noexcept {
    return T::one();
  }

  T operator()(T const&) const noexcept {
    return T::one();
  }
};

Template Parameters
  • TElementType – the type of the elements of a semigroup.

  • TSfinae – this template parameter can be used for SFINAE.