Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Koniarik
emlabcpp
Commits
2ad186e0
Commit
2ad186e0
authored
Apr 20, 2021
by
Jan Koniarik
Browse files
added convert_to function
parent
c303b7ab
Pipeline
#80779
passed with stage
in 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/emlabcpp/algorithm.h
View file @
2ad186e0
...
...
@@ -29,6 +29,14 @@ struct [[deprecated]] identity {
}
};
template
<
typename
T
>
struct
convert_to
{
template
<
typename
U
>
constexpr
T
operator
()(
U
&&
src
)
const
noexcept
(
noexcept
(
T
{
std
::
forward
<
U
>
(
src
)}))
{
return
T
{
std
::
forward
<
U
>
(
src
)};
}
};
/// returns sign of variable T: -1,0,1
template
<
typename
T
>
constexpr
int
sign
(
T
&&
val
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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