I have a templated class and a type that depends on the template. How can I use this type in my .cpp file?
object.hpp:
using pair_d = std::pair<double, double>;
using pair_f = std::pair<float, float>;
template <typename T>
class Object {
public:
static_assert(std::is_same<T, float>::value ||
std::is_same<T, double>::value, "Type not allowed");
using pair = typename std::conditional<std::is_same<T, float>::value,
pair_f, pair_d>::type;
// function using the conditional type
const pair doSomething(T, T) const;
}
object.cpp
#include "object.hpp"
template <typename T>
const pair Object<T>::doSomething(T t1, T t2) const {
// ....
}
But the I get:
error: unknown type name 'pair'
How can I use the type 'pair' in my .cpp file?