Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
b342c373
Commit
b342c373
authored
Sep 10, 2020
by
Henry Schreiner
Committed by
Henry Schreiner
Sep 15, 2020
Browse files
style: clang-tidy: modernize-use-using
parent
96e6a8d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
22 deletions
+23
-22
.clang-tidy
.clang-tidy
+1
-0
include/pybind11/chrono.h
include/pybind11/chrono.h
+3
-3
include/pybind11/detail/common.h
include/pybind11/detail/common.h
+9
-9
include/pybind11/numpy.h
include/pybind11/numpy.h
+1
-1
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+1
-1
tests/test_class.cpp
tests/test_class.cpp
+8
-8
No files found.
.clang-tidy
View file @
b342c373
...
...
@@ -5,6 +5,7 @@ Checks: '
llvm-namespace-comment,
modernize-use-override,
readability-container-size-empty,
modernize-use-using,
'
HeaderFilterRegex: 'pybind11/.*h'
include/pybind11/chrono.h
View file @
b342c373
...
...
@@ -33,9 +33,9 @@ PYBIND11_NAMESPACE_BEGIN(detail)
template
<
typename
type
>
class
duration_caster
{
public:
typedef
typename
type
::
rep
rep
;
typedef
typename
type
::
period
period
;
using
period
=
typename
type
::
period
;
typedef
std
::
chrono
::
duration
<
uint_fast32_t
,
std
::
ratio
<
86400
>>
days
;
using
days
=
std
::
chrono
::
duration
<
uint_fast32_t
,
std
::
ratio
<
86400
>>
;
bool
load
(
handle
src
,
bool
)
{
using
namespace
std
::
chrono
;
...
...
@@ -98,7 +98,7 @@ public:
// This is for casting times on the system clock into datetime.datetime instances
template
<
typename
Duration
>
class
type_caster
<
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
,
Duration
>>
{
public:
type
def
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
,
Duration
>
type
;
using
type
=
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
,
Duration
>
;
bool
load
(
handle
src
,
bool
)
{
using
namespace
std
::
chrono
;
...
...
include/pybind11/detail/common.h
View file @
b342c373
...
...
@@ -537,17 +537,17 @@ template <class T, template<class> class... Predicates> using satisfies_none_of
/// Strip the class from a method type
template
<
typename
T
>
struct
remove_class
{
};
template
<
typename
C
,
typename
R
,
typename
...
A
>
struct
remove_class
<
R
(
C
::*
)(
A
...)
>
{
typedef
R
type
(
A
...);
};
template
<
typename
C
,
typename
R
,
typename
...
A
>
struct
remove_class
<
R
(
C
::*
)(
A
...)
const
>
{
typedef
R
type
(
A
...);
};
template
<
typename
C
,
typename
R
,
typename
...
A
>
struct
remove_class
<
R
(
C
::*
)(
A
...)
>
{
using
type
=
R
(
A
...);
};
template
<
typename
C
,
typename
R
,
typename
...
A
>
struct
remove_class
<
R
(
C
::*
)(
A
...)
const
>
{
using
type
=
R
(
A
...);
};
/// Helper template to strip away type modifiers
template
<
typename
T
>
struct
intrinsic_type
{
typedef
T
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
const
T
>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
*>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
&>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
&&>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
const
T
[
N
]
>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
T
[
N
]
>
{
type
def
typename
intrinsic_type
<
T
>::
type
type
;
};
template
<
typename
T
>
struct
intrinsic_type
{
using
type
=
T
;
};
template
<
typename
T
>
struct
intrinsic_type
<
const
T
>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
*>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
&>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
>
struct
intrinsic_type
<
T
&&>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
const
T
[
N
]
>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
,
size_t
N
>
struct
intrinsic_type
<
T
[
N
]
>
{
using
type
=
typename
intrinsic_type
<
T
>::
type
;
};
template
<
typename
T
>
using
intrinsic_t
=
typename
intrinsic_type
<
T
>::
type
;
/// Helper type to replace 'void' in some expressions
...
...
include/pybind11/numpy.h
View file @
b342c373
...
...
@@ -281,7 +281,7 @@ template <typename T> struct is_complex : std::false_type { };
template
<
typename
T
>
struct
is_complex
<
std
::
complex
<
T
>>
:
std
::
true_type
{
};
template
<
typename
T
>
struct
array_info_scalar
{
typedef
T
type
;
using
type
=
T
;
static
constexpr
bool
is_array
=
false
;
static
constexpr
bool
is_empty
=
false
;
static
constexpr
auto
extents
=
_
(
""
);
...
...
include/pybind11/pybind11.h
View file @
b342c373
...
...
@@ -1789,7 +1789,7 @@ template <return_value_policy Policy = return_value_policy::reference_internal,
typename
KeyType
=
decltype
((
*
std
::
declval
<
Iterator
>()).
first
),
typename
...
Extra
>
iterator
make_key_iterator
(
Iterator
first
,
Sentinel
last
,
Extra
&&
...
extra
)
{
typedef
detail
::
iterator_state
<
Iterator
,
Sentinel
,
true
,
Policy
>
state
;
using
state
=
detail
::
iterator_state
<
Iterator
,
Sentinel
,
true
,
Policy
>
;
if
(
!
detail
::
get_type_info
(
typeid
(
state
),
false
))
{
class_
<
state
>
(
handle
(),
"iterator"
,
pybind11
::
module_local
())
...
...
tests/test_class.cpp
View file @
b342c373
...
...
@@ -425,14 +425,14 @@ template <int N> class BreaksBase { public:
};
template
<
int
N
>
class
BreaksTramp
:
public
BreaksBase
<
N
>
{};
// These should all compile just fine:
typedef
py
::
class_
<
BreaksBase
<
1
>
,
std
::
unique_ptr
<
BreaksBase
<
1
>>
,
BreaksTramp
<
1
>>
DoesntBreak1
;
typedef
py
::
class_
<
BreaksBase
<
2
>
,
BreaksTramp
<
2
>
,
std
::
unique_ptr
<
BreaksBase
<
2
>>>
DoesntBreak2
;
typedef
py
::
class_
<
BreaksBase
<
3
>
,
std
::
unique_ptr
<
BreaksBase
<
3
>>>
DoesntBreak3
;
typedef
py
::
class_
<
BreaksBase
<
4
>
,
BreaksTramp
<
4
>>
DoesntBreak4
;
typedef
py
::
class_
<
BreaksBase
<
5
>>
DoesntBreak5
;
typedef
py
::
class_
<
BreaksBase
<
6
>
,
std
::
shared_ptr
<
BreaksBase
<
6
>>
,
BreaksTramp
<
6
>>
DoesntBreak6
;
typedef
py
::
class_
<
BreaksBase
<
7
>
,
BreaksTramp
<
7
>
,
std
::
shared_ptr
<
BreaksBase
<
7
>>>
DoesntBreak7
;
typedef
py
::
class_
<
BreaksBase
<
8
>
,
std
::
shared_ptr
<
BreaksBase
<
8
>>>
DoesntBreak8
;
using
DoesntBreak1
=
py
::
class_
<
BreaksBase
<
1
>
,
std
::
unique_ptr
<
BreaksBase
<
1
>>
,
BreaksTramp
<
1
>>
;
using
DoesntBreak2
=
py
::
class_
<
BreaksBase
<
2
>
,
BreaksTramp
<
2
>
,
std
::
unique_ptr
<
BreaksBase
<
2
>>>
;
using
DoesntBreak3
=
py
::
class_
<
BreaksBase
<
3
>
,
std
::
unique_ptr
<
BreaksBase
<
3
>>>
;
using
DoesntBreak4
=
py
::
class_
<
BreaksBase
<
4
>
,
BreaksTramp
<
4
>>
;
using
DoesntBreak5
=
py
::
class_
<
BreaksBase
<
5
>>
;
using
DoesntBreak6
=
py
::
class_
<
BreaksBase
<
6
>
,
std
::
shared_ptr
<
BreaksBase
<
6
>>
,
BreaksTramp
<
6
>>
;
using
DoesntBreak7
=
py
::
class_
<
BreaksBase
<
7
>
,
BreaksTramp
<
7
>
,
std
::
shared_ptr
<
BreaksBase
<
7
>>>
;
using
DoesntBreak8
=
py
::
class_
<
BreaksBase
<
8
>
,
std
::
shared_ptr
<
BreaksBase
<
8
>>>
;
#define CHECK_BASE(N) static_assert(std::is_same<typename DoesntBreak##N::type, BreaksBase<N>>::value, \
"DoesntBreak" #N " has wrong type!")
CHECK_BASE
(
1
);
CHECK_BASE
(
2
);
CHECK_BASE
(
3
);
CHECK_BASE
(
4
);
CHECK_BASE
(
5
);
CHECK_BASE
(
6
);
CHECK_BASE
(
7
);
CHECK_BASE
(
8
);
...
...
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