Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
tnl-dev
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TNL
tnl-dev
Commits
9cf16a91
Commit
9cf16a91
authored
Aug 30, 2019
by
Jakub Klinkovský
Committed by
Tomáš Oberhuber
Sep 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed HasConstexprGetSizeMethod trait class to work with scalar types
parent
0e9e9c89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
20 deletions
+29
-20
src/TNL/TypeTraits.h
src/TNL/TypeTraits.h
+29
-20
No files found.
src/TNL/TypeTraits.h
View file @
9cf16a91
...
...
@@ -127,25 +127,35 @@ struct HasConstexprGetSizeMethod
{
private:
// implementation adopted from here: https://stackoverflow.com/a/50169108
// disable nvcc warning: invalid narrowing conversion from "unsigned int" to "int"
// (the implementation is based on the conversion)
#ifdef __NVCC__
template
<
bool
hasGetSize
=
HasGetSizeMethod
<
T
>
::
value
,
typename
=
void
>
struct
impl
{
// disable nvcc warning: invalid narrowing conversion from "unsigned int" to "int"
// (the implementation is based on the conversion)
#ifdef __NVCC__
#pragma push
#pragma diag_suppress 2361
#endif
#endif
template
<
typename
M
,
M
method
>
static
constexpr
std
::
true_type
is_constexpr_impl
(
decltype
(
int
{((
*
method
)(),
0U
)})
);
#ifdef __NVCC__
#ifdef __NVCC__
#pragma pop
#endif
#endif
template
<
typename
M
,
M
method
>
static
constexpr
std
::
false_type
is_constexpr_impl
(...);
using
type
=
decltype
(
is_constexpr_impl
<
decltype
(
&
T
::
getSize
),
&
T
::
getSize
>
(
0
));
// 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
};
// 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:
static
constexpr
bool
value
=
type
::
value
;
...
...
@@ -160,7 +170,6 @@ public:
template
<
typename
T
>
struct
IsStaticArrayType
:
public
std
::
integral_constant
<
bool
,
HasGetSizeMethod
<
T
>::
value
&&
HasConstexprGetSizeMethod
<
T
>::
value
&&
HasSubscriptOperator
<
T
>::
value
>
{};
...
...
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