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
260bc58f
Commit
260bc58f
authored
Jan 18, 2016
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved SFINAE in type_caster_generic (closes #70)
parent
92b2f452
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
include/pybind11/cast.h
+2
-2
include/pybind11/common.h
+8
-0
No files found.
include/pybind11/cast.h
View file @
260bc58f
...
@@ -209,11 +209,11 @@ public:
...
@@ -209,11 +209,11 @@ public:
operator
type
*
()
{
return
(
type
*
)
value
;
}
operator
type
*
()
{
return
(
type
*
)
value
;
}
operator
type
&
()
{
return
*
((
type
*
)
value
);
}
operator
type
&
()
{
return
*
((
type
*
)
value
);
}
protected
:
protected
:
template
<
typename
T
=
type
,
typename
std
::
enable_if
<
std
::
is_copy_constructible
<
T
>::
value
,
int
>::
type
=
0
>
template
<
typename
T
=
type
,
typename
std
::
enable_if
<
detail
::
is_copy_constructible
<
T
>::
value
,
int
>::
type
=
0
>
static
void
*
copy_constructor
(
const
void
*
arg
)
{
static
void
*
copy_constructor
(
const
void
*
arg
)
{
return
new
type
(
*
((
const
type
*
)
arg
));
return
new
type
(
*
((
const
type
*
)
arg
));
}
}
template
<
typename
T
=
type
,
typename
std
::
enable_if
<!
std
::
is_copy_constructible
<
T
>::
value
,
int
>::
type
=
0
>
template
<
typename
T
=
type
,
typename
std
::
enable_if
<!
detail
::
is_copy_constructible
<
T
>::
value
,
int
>::
type
=
0
>
static
void
*
copy_constructor
(
const
void
*
)
{
return
nullptr
;
}
static
void
*
copy_constructor
(
const
void
*
)
{
return
nullptr
;
}
};
};
...
...
include/pybind11/common.h
View file @
260bc58f
...
@@ -240,6 +240,14 @@ template <typename T> struct intrinsic_type<T&&> { typedef type
...
@@ -240,6 +240,14 @@ template <typename T> struct intrinsic_type<T&&> { typedef type
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
const
T
[
N
]
>
{
typedef
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
const
T
[
N
]
>
{
typedef
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
T
[
N
]
>
{
typedef
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
T
[
N
]
>
{
typedef
typename
intrinsic_type
<
T
>::
type
type
;
};
/** \brief SFINAE helper class to check if a copy constructor is usable (in contrast to
* std::is_copy_constructible, this class also checks if the 'new' operator is accessible */
template
<
typename
T
>
struct
is_copy_constructible
{
template
<
typename
T2
>
static
std
::
true_type
test
(
decltype
(
new
T2
(
std
::
declval
<
T2
>
()))
*
);
template
<
typename
T2
>
static
std
::
false_type
test
(...);
static
const
bool
value
=
std
::
is_same
<
std
::
true_type
,
decltype
(
test
<
T
>
(
nullptr
))
>::
value
;
};
/// Helper type to replace 'void' in some expressions
/// Helper type to replace 'void' in some expressions
struct
void_type
{
};
struct
void_type
{
};
...
...
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