From 7d46c6f60dc3ed607260e8d51e76768827ae29fa Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Sat, 14 Jan 2017 11:25:28 -0500 Subject: [PATCH] Make is_template_base_of ignore cv qualification `is_template_base_of` fails when `T` is `const` (because its implementation relies on being able to convert a `T*` to a `Base*`, which won't work when `T` is const). (This also agrees with std::is_base_of, which ignores cv qualification.) --- include/pybind11/common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 1db822306..ef94f3854 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -378,9 +378,11 @@ inline internals &get_internals(); #ifdef PYBIND11_CPP14 using std::enable_if_t; using std::conditional_t; +using std::remove_cv_t; #else template using enable_if_t = typename std::enable_if::type; template using conditional_t = typename std::conditional::type; +template using remove_cv_t = typename std::remove_cv::type; #endif /// Index sequences @@ -499,9 +501,9 @@ struct is_template_base_of_impl { /// `is_template_base_of` is true if `struct T : Base {}` where U can be anything template class Base, typename T> #if !defined(_MSC_VER) -using is_template_base_of = decltype(is_template_base_of_impl::check((T*)nullptr)); +using is_template_base_of = decltype(is_template_base_of_impl::check((remove_cv_t*)nullptr)); #else // MSVC2015 has trouble with decltype in template aliases -struct is_template_base_of : decltype(is_template_base_of_impl::check((T*)nullptr)) { }; +struct is_template_base_of : decltype(is_template_base_of_impl::check((remove_cv_t*)nullptr)) { }; #endif /// Check if T is std::shared_ptr where U can be anything