Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
73f56830
Commit
73f56830
authored
Jun 26, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add detail::is_pod_struct<T> helper
parent
d0bafd90
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
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