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
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michael Gardner
waLBerla
Commits
f1929a56
Commit
f1929a56
authored
4 years ago
by
Christian Godenschwager
Committed by
Michael Kuron
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add user defined literal _r for real_t
parent
1aa0814c
Branches
Branches containing commit
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
+4
-0
4 additions, 0 deletions
tests/core/DataTypesTest.cpp
with
6 additions
and
0 deletions
src/core/DataTypes.h
+
2
−
0
View file @
f1929a56
...
...
@@ -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
+
4
−
0
View file @
f1929a56
...
...
@@ -52,5 +52,9 @@ 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
));
WALBERLA_CHECK_IDENTICAL
(
1
_r
,
real_c
(
1
));
WALBERLA_CHECK_IDENTICAL
(
-
1
_r
,
real_c
(
-
1
));
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