Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waLBerla
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Vögl
waLBerla
Commits
0ffb51aa
Commit
0ffb51aa
authored
4 years ago
by
Sebastian Eibl
Browse files
Options
Downloads
Patches
Plain Diff
user defined literal _r for real_t
parent
1aa0814c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/DataTypes.h
+2
-0
2 additions, 0 deletions
src/core/DataTypes.h
tests/core/DataTypesTest.cpp
+2
-0
2 additions, 0 deletions
tests/core/DataTypesTest.cpp
with
4 additions
and
0 deletions
src/core/DataTypes.h
+
2
−
0
View file @
0ffb51aa
...
...
@@ -163,6 +163,8 @@ typedef double real_t;
typedef
float
real_t
;
#endif
inline
real_t
operator
""
_r
(
long
double
t
)
{
return
static_cast
<
real_t
>
(
t
);
}
inline
real_t
operator
""
_r
(
unsigned
long
long
int
t
)
{
return
static_cast
<
real_t
>
(
t
);
}
template
<
typename
T
>
inline
real_t
real_c
(
T
t
)
{
return
numeric_cast
<
real_t
>
(
t
);
}
///< cast to type real_t using "real_c(x)"
template
<
typename
T
>
inline
double
double_c
(
T
t
)
{
return
numeric_cast
<
double
>
(
t
);
}
///< cast to type double
template
<
typename
T
>
inline
float
float_c
(
T
t
)
{
return
numeric_cast
<
float
>
(
t
);
}
///< cast to type float
...
...
This diff is collapsed.
Click to expand it.
tests/core/DataTypesTest.cpp
+
2
−
0
View file @
0ffb51aa
...
...
@@ -52,5 +52,7 @@ int main( int /*argc*/, char** /*argv*/ )
WALBERLA_CHECK_EQUAL
(
math
::
int_ld
<
2
>::
exp
,
1
);
WALBERLA_CHECK_EQUAL
(
math
::
int_ld
<
1
>::
exp
,
0
);
WALBERLA_CHECK_IDENTICAL
(
1.23456
_r
,
real_c
(
1.23456
));
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment