F
Focca
I have a template function specialized with some base types:
template <typename T>
void print(const T &value);
template <>
void print<bool>(const bool &value)
{
// ...
}
template <>
void print<int>(const int &value)
{
// ...
}
Now consider a class "Value" that holds a base type (bool, int)
template <typename T>
class Value
{
public:
const T & get() const
{
return m_value;
}
T m_value;
};
When I specialize the "print" function I need to write something like this:
template <>
void print<Value<bool> >(const Value<bool> &value)
{
print(value.get());
}
template <>
void print<Value<int> >(const Value<int> &value)
{
print(value.get());
}
My question is: can I write a "template" specialized function?
I'm thinking about this:
template <>
void print<template <typename T> Value>(const Value<T> &value)
{
print(value.get());
}
or
template <typename T>
template <>
void print<Wrapper<T> >(const Wrapper<T> &value)
{
print(value.get());
}
Plz help, thanks
template <typename T>
void print(const T &value);
template <>
void print<bool>(const bool &value)
{
// ...
}
template <>
void print<int>(const int &value)
{
// ...
}
Now consider a class "Value" that holds a base type (bool, int)
template <typename T>
class Value
{
public:
const T & get() const
{
return m_value;
}
T m_value;
};
When I specialize the "print" function I need to write something like this:
template <>
void print<Value<bool> >(const Value<bool> &value)
{
print(value.get());
}
template <>
void print<Value<int> >(const Value<int> &value)
{
print(value.get());
}
My question is: can I write a "template" specialized function?
I'm thinking about this:
template <>
void print<template <typename T> Value>(const Value<T> &value)
{
print(value.get());
}
or
template <typename T>
template <>
void print<Wrapper<T> >(const Wrapper<T> &value)
{
print(value.get());
}
Plz help, thanks