Skip to content

Commit 879dff4

Browse files
committed
Placate MSVC
1 parent 459d0f6 commit 879dff4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/nanobind/nb_class.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,7 @@ struct init<detail::init_using_factory_tag, Func, Return(Args...)>
389389
NB_INLINE void execute(Class &cl, const Extra&... extra) {
390390
using Type = typename Class::Type;
391391
using Alias = typename Class::Alias;
392-
constexpr bool has_alias = !std::is_same_v<Type, Alias>;
393-
if constexpr (!has_alias) {
392+
if constexpr (std::is_same_v<Type, Alias>) {
394393
static_assert(std::is_constructible_v<Type, Return>,
395394
"nb::init() factory function must return an instance "
396395
"of the type by value, or something that can "
@@ -404,7 +403,8 @@ struct init<detail::init_using_factory_tag, Func, Return(Args...)>
404403
cl.def(
405404
"__init__",
406405
[func_ = (detail::forward_t<Func>) func](pointer_and_handle<Type> v, Args... args) {
407-
if constexpr (has_alias && std::is_constructible_v<Type, Return>) {
406+
if constexpr (!std::is_same_v<Type, Alias> &&
407+
std::is_constructible_v<Type, Return>) {
408408
if (!detail::nb_inst_python_derived(v.h.ptr())) {
409409
new (v.p) Type{ func_((detail::forward_t<Args>) args...) };
410410
return;

0 commit comments

Comments
 (0)