Skip to content

Allow nullptr to be bindable to a function expecting a 'pointer argument' #928

@trueqbit

Description

@trueqbit

When using the 'pointer-passing interface' feature, I'd like to be able to just pass a nullptr to a function expecting a 'pointer argument' instead of going through the cumbersome effort of creating typed 'null pointers'. This is also a C++ programmer's natural expectation.

E.g., given

struct remember_fn {
    int64 operator()(int64 value, carray_pointer_arg<int64> pv) const {
        if(int64* observer = pv) {
            *observer = value;
        }
        return value;
    }

    static constexpr const char* name() {
        return "remember";
    }
};

Use nullptr

select(func<remember_fn(&Object::id, nullptr))

instead of

select(func<remember_fn(&Object::id, statically_bindable_pointer<carray_pvt>(nullptr))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions