Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
aaf4fcc6
Commit
aaf4fcc6
authored
Jun 29, 2018
by
Paul
Browse files
Remove the any_type
parent
83b91229
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
10 deletions
+22
-10
src/include/rtg/raw_data.hpp
src/include/rtg/raw_data.hpp
+17
-3
src/include/rtg/requires.hpp
src/include/rtg/requires.hpp
+4
-1
src/include/rtg/shape.hpp
src/include/rtg/shape.hpp
+1
-5
src/shape.cpp
src/shape.cpp
+0
-1
No files found.
src/include/rtg/raw_data.hpp
View file @
aaf4fcc6
...
@@ -89,13 +89,27 @@ struct raw_data : raw_data_base
...
@@ -89,13 +89,27 @@ struct raw_data : raw_data_base
assert
(
self
->
single
());
assert
(
self
->
single
());
return
self
->
template
at
<
T
>();
return
self
->
template
at
<
T
>();
}
}
template
<
class
T
>
using
is_data_ptr
=
bool_c
<
(
std
::
is_void
<
T
>
{}
or
std
::
is_same
<
char
,
std
::
remove_cv_t
<
T
>>
{}
or
std
::
is_same
<
unsigned
char
,
std
::
remove_cv_t
<
T
>>
{})
>
;
template
<
class
T
>
using
get_data_type
=
std
::
conditional_t
<
is_data_ptr
<
T
>
{},
float
,
T
>
;
template
<
class
T
>
bool
matches
()
const
{
return
is_data_ptr
<
T
>
{}
||
self
->
get_shape
().
type
()
==
rtg
::
shape
::
get_type
<
get_data_type
<
T
>>
{};
}
template
<
class
T
>
template
<
class
T
>
operator
T
*
()
operator
T
*
()
{
{
using
type
=
std
::
remove_cv_t
<
T
>
;
using
type
=
std
::
remove_cv_t
<
T
>
;
assert
((
std
::
is_void
<
T
>
{}
or
std
::
is_same
<
char
,
type
>
{}
or
assert
(
matches
<
T
>
());
std
::
is_same
<
unsigned
char
,
type
>
{}
or
self
->
get_shape
().
type
()
==
rtg
::
shape
::
get_type
<
T
>
{}));
return
reinterpret_cast
<
type
*>
(
self
->
data
());
return
reinterpret_cast
<
type
*>
(
self
->
data
());
}
}
};
};
...
...
src/include/rtg/requires.hpp
View file @
aaf4fcc6
...
@@ -10,10 +10,13 @@ struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
...
@@ -10,10 +10,13 @@ struct and_ : std::is_same<and_<Bs...>, and_<(Bs || true)...>> // NOLINT
{
{
};
};
template
<
bool
B
>
using
bool_c
=
std
::
integral_constant
<
bool
,
B
>
;
#ifdef CPPCHECK
#ifdef CPPCHECK
#define RTG_REQUIRES(...) class = void
#define RTG_REQUIRES(...) class = void
#else
#else
#define RTG_REQUIRES(...) class = typename std::enable_if<and_<__VA_ARGS__,
true
>{}>::type
#define RTG_REQUIRES(...)
bool PrivateRequires ## __LINE__ = true,
class = typename std::enable_if<and_<__VA_ARGS__,
PrivateRequires ## __LINE__
>{}>::type
#endif
#endif
}
// namespace rtg
}
// namespace rtg
...
...
src/include/rtg/shape.hpp
View file @
aaf4fcc6
...
@@ -31,15 +31,12 @@ struct shape
...
@@ -31,15 +31,12 @@ struct shape
#define RTG_SHAPE_ENUM_TYPES(x, t) x,
#define RTG_SHAPE_ENUM_TYPES(x, t) x,
enum
type_t
enum
type_t
{
{
any_type
,
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_ENUM_TYPES
)
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_ENUM_TYPES
)
};
};
#undef RTG_SHAPE_ENUM_TYPES
#undef RTG_SHAPE_ENUM_TYPES
template
<
class
T
,
class
=
void
>
template
<
class
T
,
class
=
void
>
struct
get_type
:
std
::
integral_constant
<
type_t
,
any_type
>
struct
get_type
;
{
};
#define RTG_SHAPE_GET_TYPE(x, t) \
#define RTG_SHAPE_GET_TYPE(x, t) \
template <class T> \
template <class T> \
struct get_type<t, T> : std::integral_constant<type_t, x> \
struct get_type<t, T> : std::integral_constant<type_t, x> \
...
@@ -125,7 +122,6 @@ struct shape
...
@@ -125,7 +122,6 @@ struct shape
{
{
switch
(
this
->
m_type
)
switch
(
this
->
m_type
)
{
{
case
any_type
:
RTG_THROW
(
"Cannot visit the any_type"
);
#define RTG_SHAPE_VISITOR_CASE(x, t) \
#define RTG_SHAPE_VISITOR_CASE(x, t) \
case x: v(as<t>()); return;
case x: v(as<t>()); return;
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_VISITOR_CASE
)
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_VISITOR_CASE
)
...
...
src/shape.cpp
View file @
aaf4fcc6
...
@@ -109,7 +109,6 @@ std::string shape::type_string() const
...
@@ -109,7 +109,6 @@ std::string shape::type_string() const
{
{
switch
(
this
->
m_type
)
switch
(
this
->
m_type
)
{
{
case
any_type
:
return
"any"
;
#define RTG_SHAPE_TYPE_STRING_CASE(x, t) \
#define RTG_SHAPE_TYPE_STRING_CASE(x, t) \
case x: return #x;
case x: return #x;
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_TYPE_STRING_CASE
)
RTG_SHAPE_VISIT_TYPES
(
RTG_SHAPE_TYPE_STRING_CASE
)
...
...
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