Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename forward_like to avoid conflict with STL #475

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/nanobind/nb_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ using forwarded_type = std::conditional_t<std::is_lvalue_reference_v<T>,

/// Forwards a value U as rvalue or lvalue according to whether T is rvalue or lvalue; typically
/// used for forwarding a container's elements.
template <typename T, typename U> NB_INLINE forwarded_type<T, U> forward_like(U &&u) {
template <typename T, typename U> NB_INLINE forwarded_type<T, U> forward_like_(U &&u) {
return (forwarded_type<T, U>) u;
}

Expand Down
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 @@ -48,7 +48,7 @@ template <typename Array, typename Entry, size_t Size> struct array_caster {
Py_ssize_t index = 0;

for (auto &value : src) {
handle h = Caster::from_cpp(forward_like<T>(value), policy, cleanup);
handle h = Caster::from_cpp(forward_like_<T>(value), policy, cleanup);

if (!h.is_valid()) {
ret.reset();
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 @@ -75,9 +75,9 @@ template <typename Dict, typename Key, typename Val> struct dict_caster {
if (ret.is_valid()) {
for (auto &item : src) {
object k = steal(KeyCaster::from_cpp(
forward_like<T>(item.first), policy, cleanup));
forward_like_<T>(item.first), policy, cleanup));
object e = steal(ValCaster::from_cpp(
forward_like<T>(item.second), policy, cleanup));
forward_like_<T>(item.second), policy, cleanup));

if (!k.is_valid() || !e.is_valid() ||
PyDict_SetItem(ret.ptr(), k.ptr(), e.ptr()) != 0) {
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 @@ -64,7 +64,7 @@ template <typename List, typename Entry> struct list_caster {
Py_ssize_t index = 0;

for (auto &&value : src) {
handle h = Caster::from_cpp(forward_like<T>(value), policy, cleanup);
handle h = Caster::from_cpp(forward_like_<T>(value), policy, cleanup);

if (!h.is_valid()) {
ret.reset();
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 @@ -64,7 +64,7 @@ template <typename Set, typename Key> struct set_caster {
if (ret.is_valid()) {
for (auto& key : src) {
object k = steal(
Caster::from_cpp(forward_like<T>(key), policy, cleanup));
Caster::from_cpp(forward_like_<T>(key), policy, cleanup));

if (!k.is_valid() || PySet_Add(ret.ptr(), k.ptr()) != 0) {
ret.reset();
Expand Down
2 changes: 1 addition & 1 deletion include/nanobind/stl/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct type_caster<std::optional<T>> {
if (!value)
return none().release();

return Caster::from_cpp(forward_like<T_>(*value), policy, cleanup);
return Caster::from_cpp(forward_like_<T_>(*value), policy, cleanup);
}
};

Expand Down
4 changes: 2 additions & 2 deletions include/nanobind/stl/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ template <typename T1, typename T2> struct type_caster<std::pair<T1, T2>> {
static handle from_cpp(T &&value, rv_policy policy,
cleanup_list *cleanup) noexcept {
object o1 = steal(
Caster1::from_cpp(forward_like<T>(value.first), policy, cleanup));
Caster1::from_cpp(forward_like_<T>(value.first), policy, cleanup));
if (!o1.is_valid())
return {};

object o2 = steal(
Caster2::from_cpp(forward_like<T>(value.second), policy, cleanup));
Caster2::from_cpp(forward_like_<T>(value.second), policy, cleanup));
if (!o2.is_valid())
return {};

Expand Down
2 changes: 1 addition & 1 deletion include/nanobind/stl/tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ template <typename... Ts> struct type_caster<std::tuple<Ts...>> {
bool success =
(... &&
((o[Is] = steal(make_caster<Ts>::from_cpp(
forward_like<T>(std::get<Is>(value)), policy, cleanup))),
forward_like_<T>(std::get<Is>(value)), policy, cleanup))),
o[Is].is_valid()));

if (!success)
Expand Down