Skip to content

Commit b46fd73

Browse files
committed
Remove detail:: qualifications (fix MSVC strict mode)
`using detail::_` is causing MSVC some trouble, so backport the `using namespace detail` from master (which also removes a few now-superfluous `detail::` qualifications).
1 parent 54d31db commit b46fd73

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

include/pybind11/numpy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,9 @@ struct format_descriptor<T, detail::enable_if_t<std::is_enum<T>::value>> {
946946
template <typename T>
947947
struct format_descriptor<T, detail::enable_if_t<detail::array_info<T>::is_array>> {
948948
static std::string format() {
949-
using detail::_;
950-
PYBIND11_DESCR extents = _("(") + detail::array_info<T>::extents() + _(")");
951-
return extents.text() + format_descriptor<detail::remove_all_extents_t<T>>::format();
949+
using namespace detail;
950+
PYBIND11_DESCR extents = _("(") + array_info<T>::extents() + _(")");
951+
return extents.text() + format_descriptor<remove_all_extents_t<T>>::format();
952952
}
953953
};
954954

include/pybind11/pybind11.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class cpp_function : public function {
9292
/// Special internal constructor for functors, lambda functions, etc.
9393
template <typename Func, typename Return, typename... Args, typename... Extra>
9494
void initialize(Func &&f, Return (*)(Args...), const Extra&... extra) {
95-
95+
using namespace detail;
9696
struct capture { detail::remove_reference_t<Func> f; };
9797

9898
/* Store the function including any extra state it might have (e.g. a lambda capture object) */
@@ -112,58 +112,57 @@ class cpp_function : public function {
112112
# pragma GCC diagnostic pop
113113
#endif
114114
if (!std::is_trivially_destructible<Func>::value)
115-
rec->free_data = [](detail::function_record *r) { ((capture *) &r->data)->~capture(); };
115+
rec->free_data = [](function_record *r) { ((capture *) &r->data)->~capture(); };
116116
} else {
117117
rec->data[0] = new capture { std::forward<Func>(f) };
118-
rec->free_data = [](detail::function_record *r) { delete ((capture *) r->data[0]); };
118+
rec->free_data = [](function_record *r) { delete ((capture *) r->data[0]); };
119119
}
120120

121121
/* Type casters for the function arguments and return value */
122-
using cast_in = detail::argument_loader<Args...>;
123-
using cast_out = detail::make_caster<
124-
detail::conditional_t<std::is_void<Return>::value, detail::void_type, Return>
122+
using cast_in = argument_loader<Args...>;
123+
using cast_out = make_caster<
124+
conditional_t<std::is_void<Return>::value, void_type, Return>
125125
>;
126126

127-
static_assert(detail::expected_num_args<Extra...>(sizeof...(Args), cast_in::has_args, cast_in::has_kwargs),
127+
static_assert(expected_num_args<Extra...>(sizeof...(Args), cast_in::has_args, cast_in::has_kwargs),
128128
"The number of argument annotations does not match the number of function arguments");
129129

130130
/* Dispatch code which converts function arguments and performs the actual function call */
131-
rec->impl = [](detail::function_call &call) -> handle {
131+
rec->impl = [](function_call &call) -> handle {
132132
cast_in args_converter;
133133

134134
/* Try to cast the function arguments into the C++ domain */
135135
if (!args_converter.load_args(call))
136136
return PYBIND11_TRY_NEXT_OVERLOAD;
137137

138138
/* Invoke call policy pre-call hook */
139-
detail::process_attributes<Extra...>::precall(call);
139+
process_attributes<Extra...>::precall(call);
140140

141141
/* Get a pointer to the capture object */
142142
auto data = (sizeof(capture) <= sizeof(call.func.data)
143143
? &call.func.data : call.func.data[0]);
144144
capture *cap = const_cast<capture *>(reinterpret_cast<const capture *>(data));
145145

146146
/* Override policy for rvalues -- usually to enforce rvp::move on an rvalue */
147-
const auto policy = detail::return_value_policy_override<Return>::policy(call.func.policy);
147+
const auto policy = return_value_policy_override<Return>::policy(call.func.policy);
148148

149149
/* Function scope guard -- defaults to the compile-to-nothing `void_type` */
150-
using Guard = detail::extract_guard_t<Extra...>;
150+
using Guard = extract_guard_t<Extra...>;
151151

152152
/* Perform the function call */
153153
handle result = cast_out::cast(
154154
std::move(args_converter).template call<Return, Guard>(cap->f), policy, call.parent);
155155

156156
/* Invoke call policy post-call hook */
157-
detail::process_attributes<Extra...>::postcall(call, result);
157+
process_attributes<Extra...>::postcall(call, result);
158158

159159
return result;
160160
};
161161

162162
/* Process any user-provided function attributes */
163-
detail::process_attributes<Extra...>::init(extra..., rec);
163+
process_attributes<Extra...>::init(extra..., rec);
164164

165165
/* Generate a readable signature describing the function's arguments and return value types */
166-
using detail::descr; using detail::_;
167166
PYBIND11_DESCR signature = _("(") + cast_in::arg_names() + _(") -> ") + cast_out::name();
168167

169168
/* Register the function with Python from generic (non-templated) code */

0 commit comments

Comments
 (0)