Skip to content

Commit 5e352ea

Browse files
committed
Placate MSVC
1 parent 342677a commit 5e352ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/nanobind/nb_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,7 @@ struct init<detail::init_using_factory_tag, Func, Return(Args...)> {
377377
NB_INLINE void execute(Class &cl, const Extra&... extra) {
378378
using Type = typename Class::Type;
379379
using Alias = typename Class::Alias;
380-
constexpr bool has_alias = !std::is_same_v<Type, Alias>;
381-
if constexpr (!has_alias) {
380+
if constexpr (std::is_same_v<Type, Alias>) {
382381
static_assert(std::is_constructible_v<Type, Return>,
383382
"nb::init() factory function must return an instance "
384383
"of the type by value, or something that can "
@@ -392,7 +391,8 @@ struct init<detail::init_using_factory_tag, Func, Return(Args...)> {
392391
cl.def(
393392
"__init__",
394393
[func_ = (detail::forward_t<Func>) func](pointer_and_handle<Type> v, Args... args) {
395-
if constexpr (has_alias && std::is_constructible_v<Type, Return>) {
394+
if constexpr (!std::is_same_v<Type, Alias> &&
395+
std::is_constructible_v<Type, Return>) {
396396
if (!detail::nb_inst_python_derived(v.h.ptr())) {
397397
new (v.p) Type{ func_((detail::forward_t<Args>) args...) };
398398
return;

0 commit comments

Comments
 (0)