SyTen
syten::IdentityType< Type > Struct Template Reference

Identity type template to hinder type deduction. More...

#include <types.h>

Detailed Description

template<typename Type>
struct syten::IdentityType< Type >

Identity type template to hinder type deduction.

This

template<typename T> T add(T x, T y) { };
add(23., 1)

will fail as T is deduced to both double and int.

template<typename T> T add(T x, typename IdentityType<T>::type y) { };
add(23., 1)

will not allow type deduction on the second argument and hence force the 1 to be read as double. However, note that this can lead to unintended consequences, i.e.

add(1,23.5)

will deduce T to int and hence cast 23.5 to int.


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