Commit 844efdd7 authored by André Anjos's avatar André Anjos 💬
Browse files

Correctly implement template specialization. Closes bob.io.base#14

parent 19c345f9
Pipeline #3689 passed with stages
in 49 minutes and 17 seconds
......@@ -19,13 +19,23 @@ namespace bob { namespace core {
namespace array {
template<typename T, typename U> T scalar_cast(const U& u) {
template<typename T, typename U>
struct scalar_cast_impl {
static T f(const U& u) {
return static_cast<T>(u);
}
};
template<typename T, typename U> T scalar_cast(const std::complex<U>& u) {
template<typename T, typename U>
struct scalar_cast_impl<T, std::complex<U> > {
static T f(const std::complex<U>& u) {
return static_cast<T>(u.real());
}
};
template<typename T, typename U> T scalar_cast(const U& u) {
return scalar_cast_impl<T,U>::f(u);
}
// when using matching complex or non-complex T and U
template<typename T, typename U>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment