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
pybind11
Commits
73f56830
Commit
73f56830
authored
Jun 26, 2016
by
Ivan Smirnov
Browse files
Add detail::is_pod_struct<T> helper
parent
d0bafd90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
include/pybind11/numpy.h
include/pybind11/numpy.h
+17
-16
No files found.
include/pybind11/numpy.h
View file @
73f56830
...
@@ -23,7 +23,19 @@
...
@@ -23,7 +23,19 @@
#endif
#endif
NAMESPACE_BEGIN
(
pybind11
)
NAMESPACE_BEGIN
(
pybind11
)
namespace
detail
{
template
<
typename
type
,
typename
SFINAE
=
void
>
struct
npy_format_descriptor
{
};
}
namespace
detail
{
template
<
typename
type
,
typename
SFINAE
=
void
>
struct
npy_format_descriptor
{
};
template
<
typename
T
>
struct
is_pod_struct
{
enum
{
value
=
std
::
is_pod
<
T
>::
value
&&
// offsetof only works correctly for POD types
!
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
T
,
float
>::
value
&&
!
std
::
is_same
<
T
,
bool
>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
float
>>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
double
>>::
value
};
};
}
class
array
:
public
buffer
{
class
array
:
public
buffer
{
public:
public:
...
@@ -156,14 +168,8 @@ public:
...
@@ -156,14 +168,8 @@ public:
}
}
};
};
template
<
typename
T
>
struct
format_descriptor
template
<
typename
T
>
<
T
,
typename
std
::
enable_if
<
std
::
is_pod
<
T
>::
value
&&
struct
format_descriptor
<
T
,
typename
std
::
enable_if
<
detail
::
is_pod_struct
<
T
>::
value
>::
type
>
{
!
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
T
,
float
>::
value
&&
!
std
::
is_same
<
T
,
bool
>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
float
>>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
double
>>::
value
>::
type
>
{
static
const
char
*
format
()
{
static
const
char
*
format
()
{
return
detail
::
npy_format_descriptor
<
T
>::
format
();
return
detail
::
npy_format_descriptor
<
T
>::
format
();
}
}
...
@@ -217,13 +223,8 @@ struct field_descriptor {
...
@@ -217,13 +223,8 @@ struct field_descriptor {
object
descr
;
object
descr
;
};
};
template
<
typename
T
>
struct
npy_format_descriptor
template
<
typename
T
>
<
T
,
typename
std
::
enable_if
<
std
::
is_pod
<
T
>::
value
&&
// offsetof only works correctly for POD types
struct
npy_format_descriptor
<
T
,
typename
std
::
enable_if
<
is_pod_struct
<
T
>::
value
>::
type
>
!
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_same
<
T
,
float
>::
value
&&
!
std
::
is_same
<
T
,
bool
>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
float
>>::
value
&&
!
std
::
is_same
<
T
,
std
::
complex
<
double
>>::
value
>::
type
>
{
{
static
PYBIND11_DESCR
name
()
{
return
_
(
"user-defined"
);
}
static
PYBIND11_DESCR
name
()
{
return
_
(
"user-defined"
);
}
...
...
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