style: clang-tidy: modernize-use-using
diff --git a/.clang-tidy b/.clang-tidy
index 6df242d..294a190 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -5,6 +5,7 @@
llvm-namespace-comment,
modernize-use-override,
readability-container-size-empty,
+modernize-use-using,
'
HeaderFilterRegex: 'pybind11/.*h'
diff --git a/include/pybind11/chrono.h b/include/pybind11/chrono.h
index ac3d34e..cbe9ace 100644
--- a/include/pybind11/chrono.h
+++ b/include/pybind11/chrono.h
@@ -33,9 +33,9 @@
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 @@
// 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:
- typedef 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;
diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h
index 7d6530c..68036c7 100644
--- a/include/pybind11/detail/common.h
+++ b/include/pybind11/detail/common.h
@@ -537,17 +537,17 @@
/// 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> { typedef typename intrinsic_type<T>::type type; };
-template <typename T> struct intrinsic_type<T*> { typedef typename intrinsic_type<T>::type type; };
-template <typename T> struct intrinsic_type<T&> { typedef typename intrinsic_type<T>::type type; };
-template <typename T> struct intrinsic_type<T&&> { 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> 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
diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h
index c0b38ce..7c3ac12 100644
--- a/include/pybind11/numpy.h
+++ b/include/pybind11/numpy.h
@@ -281,7 +281,7 @@
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 = _("");
diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index 9f1736f..c6334fb 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -1789,7 +1789,7 @@
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())
diff --git a/tests/test_class.cpp b/tests/test_class.cpp
index e7eaa83..4dd4941 100644
--- a/tests/test_class.cpp
+++ b/tests/test_class.cpp
@@ -425,14 +425,14 @@
};
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);