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
fb74df50
Commit
fb74df50
authored
Oct 20, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement format/numpy descriptors for enums
parent
35995856
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
include/pybind11/numpy.h
+17
-0
No files found.
include/pybind11/numpy.h
View file @
fb74df50
...
...
@@ -552,6 +552,14 @@ template <size_t N> struct format_descriptor<std::array<char, N>> {
static
std
::
string
format
()
{
return
std
::
to_string
(
N
)
+
"s"
;
}
};
template
<
typename
T
>
struct
format_descriptor
<
T
,
detail
::
enable_if_t
<
std
::
is_enum
<
T
>::
value
>>
{
static
std
::
string
format
()
{
return
format_descriptor
<
typename
std
::
remove_cv
<
typename
std
::
underlying_type
<
T
>::
type
>::
type
>::
format
();
}
};
NAMESPACE_BEGIN
(
detail
)
template
<
typename
T
>
struct
is_std_array
:
std
::
false_type
{
};
template
<
typename
T
,
size_t
N
>
struct
is_std_array
<
std
::
array
<
T
,
N
>>
:
std
::
true_type
{
};
...
...
@@ -563,6 +571,7 @@ struct is_pod_struct {
!
std
::
is_array
<
T
>::
value
&&
!
is_std_array
<
T
>::
value
&&
!
std
::
is_integral
<
T
>::
value
&&
!
std
::
is_enum
<
T
>::
value
&&
!
std
::
is_same
<
typename
std
::
remove_cv
<
T
>::
type
,
float
>::
value
&&
!
std
::
is_same
<
typename
std
::
remove_cv
<
T
>::
type
,
double
>::
value
&&
!
std
::
is_same
<
typename
std
::
remove_cv
<
T
>::
type
,
bool
>::
value
&&
...
...
@@ -612,6 +621,14 @@ template <size_t N> struct npy_format_descriptor<char[N]> { DECL_CHAR_FMT };
template
<
size_t
N
>
struct
npy_format_descriptor
<
std
::
array
<
char
,
N
>>
{
DECL_CHAR_FMT
};
#undef DECL_CHAR_FMT
template
<
typename
T
>
struct
npy_format_descriptor
<
T
,
enable_if_t
<
std
::
is_enum
<
T
>::
value
>>
{
private
:
using
base_descr
=
npy_format_descriptor
<
typename
std
::
underlying_type
<
T
>::
type
>
;
public
:
static
PYBIND11_DESCR
name
()
{
return
base_descr
::
name
();
}
static
pybind11
::
dtype
dtype
()
{
return
base_descr
::
dtype
();
}
};
struct
field_descriptor
{
const
char
*
name
;
size_t
offset
;
...
...
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