Skip to content
Snippets Groups Projects
Commit 1034696b authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch 'fix_issue_14_io_base' into 'master'

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



See merge request !4
parents 19c345f9 844efdd7
No related branches found
No related tags found
1 merge request!4Correctly implement template specialization. Closes bob/bob.io.base#14
Pipeline #
...@@ -19,13 +19,23 @@ namespace bob { namespace core { ...@@ -19,13 +19,23 @@ namespace bob { namespace core {
namespace array { 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); 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()); 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 // when using matching complex or non-complex T and U
template<typename T, typename U> template<typename T, typename U>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment