Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
9cf16a91
There was an error fetching the commit references. Please try again later.
Commit
9cf16a91
authored
5 years ago
by
Jakub Klinkovský
Committed by
Tomáš Oberhuber
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed HasConstexprGetSizeMethod trait class to work with scalar types
parent
0e9e9c89
No related branches found
No related tags found
1 merge request
!41
Tutorials
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/TypeTraits.h
+29
-20
29 additions, 20 deletions
src/TNL/TypeTraits.h
with
29 additions
and
20 deletions
src/TNL/TypeTraits.h
+
29
−
20
View file @
9cf16a91
...
@@ -127,25 +127,35 @@ struct HasConstexprGetSizeMethod
...
@@ -127,25 +127,35 @@ struct HasConstexprGetSizeMethod
{
{
private:
private:
// implementation adopted from here: https://stackoverflow.com/a/50169108
// implementation adopted from here: https://stackoverflow.com/a/50169108
template
<
bool
hasGetSize
=
HasGetSizeMethod
<
T
>
::
value
,
typename
=
void
>
// disable nvcc warning: invalid narrowing conversion from "unsigned int" to "int"
struct
impl
// (the implementation is based on the conversion)
{
#ifdef __NVCC__
// disable nvcc warning: invalid narrowing conversion from "unsigned int" to "int"
#pragma push
// (the implementation is based on the conversion)
#pragma diag_suppress 2361
#ifdef __NVCC__
#endif
#pragma push
template
<
typename
M
,
M
method
>
#pragma diag_suppress 2361
static
constexpr
std
::
true_type
is_constexpr_impl
(
decltype
(
int
{((
*
method
)(),
0U
)})
);
#endif
#ifdef __NVCC__
template
<
typename
M
,
M
method
>
#pragma pop
static
constexpr
std
::
true_type
is_constexpr_impl
(
decltype
(
int
{((
*
method
)(),
0U
)})
);
#endif
#ifdef __NVCC__
#pragma pop
template
<
typename
M
,
M
method
>
#endif
static
constexpr
std
::
false_type
is_constexpr_impl
(...);
template
<
typename
M
,
M
method
>
using
type
=
decltype
(
is_constexpr_impl
<
decltype
(
&
T
::
getSize
),
&
T
::
getSize
>
(
0
));
static
constexpr
std
::
false_type
is_constexpr_impl
(...);
// TODO: this does not work for integral types because T::getSize does not exist
// error #276: name followed by "::" must be a class or namespace name
using
type
=
decltype
(
is_constexpr_impl
<
decltype
(
&
T
::
getSize
),
&
T
::
getSize
>
(
0
));
};
// specialization for types which don't have getSize() method at all
template
<
typename
_
>
struct
impl
<
false
,
_
>
{
using
type
=
std
::
false_type
;
};
using
type
=
typename
impl
<>::
type
;
public
:
public
:
static
constexpr
bool
value
=
type
::
value
;
static
constexpr
bool
value
=
type
::
value
;
...
@@ -160,7 +170,6 @@ public:
...
@@ -160,7 +170,6 @@ public:
template
<
typename
T
>
template
<
typename
T
>
struct
IsStaticArrayType
struct
IsStaticArrayType
:
public
std
::
integral_constant
<
bool
,
:
public
std
::
integral_constant
<
bool
,
HasGetSizeMethod
<
T
>::
value
&&
HasConstexprGetSizeMethod
<
T
>::
value
&&
HasConstexprGetSizeMethod
<
T
>::
value
&&
HasSubscriptOperator
<
T
>::
value
>
HasSubscriptOperator
<
T
>::
value
>
{};
{};
...
...
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