Skip to content

Commit

Permalink
if -> if constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Oct 18, 2023
1 parent 2e23c6a commit 1d4aeb0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/nanobind/stl/detail/nb_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ template <typename Array, typename Entry, size_t Size> struct array_caster {
Caster caster;
bool success = o != nullptr;

if (is_base_caster_v<Caster> && !std::is_pointer_v<Entry>)
if constexpr (is_base_caster_v<Caster> && !std::is_pointer_v<Entry>)
flags |= (uint8_t) cast_flags::none_disallowed;

if (success) {
Expand Down
4 changes: 2 additions & 2 deletions include/nanobind/stl/detail/nb_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ template <typename Dict, typename Key, typename Val> struct dict_caster {

uint8_t flags_key = flags, flags_val = flags;

if (is_base_caster_v<KeyCaster> && !std::is_pointer_v<Key>)
if constexpr (is_base_caster_v<KeyCaster> && !std::is_pointer_v<Key>)
flags_key |= (uint8_t) cast_flags::none_disallowed;
if (is_base_caster_v<ValCaster> && !std::is_pointer_v<Val>)
if constexpr (is_base_caster_v<ValCaster> && !std::is_pointer_v<Val>)
flags_val |= (uint8_t) cast_flags::none_disallowed;

KeyCaster key_caster;
Expand Down
2 changes: 1 addition & 1 deletion include/nanobind/stl/detail/nb_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template <typename List, typename Entry> struct list_caster {
Caster caster;
bool success = o != nullptr;

if (is_base_caster_v<Caster> && !std::is_pointer_v<Entry>)
if constexpr (is_base_caster_v<Caster> && !std::is_pointer_v<Entry>)
flags |= (uint8_t) cast_flags::none_disallowed;

for (size_t i = 0; i < size; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion include/nanobind/stl/detail/nb_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template <typename Set, typename Key> struct set_caster {
Caster key_caster;
PyObject *key;

if (is_base_caster_v<Caster> && !std::is_pointer_v<Key>)
if constexpr (is_base_caster_v<Caster> && !std::is_pointer_v<Key>)
flags |= (uint8_t) cast_flags::none_disallowed;

while ((key = PyIter_Next(iter)) != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion include/nanobind/stl/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template <typename... Ts> struct type_caster<std::variant<Ts...>> {
"type caster was registered to intercept this particular "
"type, which is not allowed.");

if (is_base_caster_v<CasterT> && !std::is_pointer_v<T>)
if constexpr (is_base_caster_v<CasterT> && !std::is_pointer_v<T>)
flags |= (uint8_t) cast_flags::none_disallowed;

CasterT caster;
Expand Down

0 comments on commit 1d4aeb0

Please sign in to comment.