Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.core
Commits
844efdd7
Commit
844efdd7
authored
Sep 14, 2016
by
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
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/core/include/bob.core/cast.h
View file @
844efdd7
...
...
@@ -19,12 +19,22 @@ namespace bob { namespace core {
namespace
array
{
template
<
typename
T
,
typename
U
>
T
scalar_cast
(
const
U
&
u
)
{
return
static_cast
<
T
>
(
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
)
{
return
static_cast
<
T
>
(
u
.
real
());
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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment