Read-Only Parameter

#include <m3ta/readonlyparameter>

Resolves the most optimal read-only parameter signature for a given type.

In other words, it returns either T or const T& depending on the size of a type T.


Any const, volatile and reference qualifiers are ignored during the resolution. As such, the types T, T &&, const T &, and so on, will all resolve to the same type.


template<typename T>
struct ReadOnlyParameter
Template Parameters:
  • T – Type to resolve.

Member Types


The most optimal read-only parameter signature for the type T.


template<typename T>
using ReadOnlyParameterT = typename ReadOnlyParameter<T>::type;

Usage Examples

using Type1 = m3ta::ReadOnlyParameterT<char>; // char
using Type2 = m3ta::ReadOnlyParameterT<std::complex<double>>; // const std::complex<double> &
using Type3 = m3ta::ReadOnlyParameterT<double *>; // double*
using Type4 = m3ta::ReadOnlyParameterT<double[32]>; // double[32]
using Type5 = m3ta::ReadOnlyParameterT<const volatile char &>; // char
using Type6 = m3ta::ReadOnlyParameterT<char &&>; // char