Skip to content

lockers: T& store(..., const T& cargo) is kinda nonsensical #5

@xparq

Description

@xparq
  • I mean if it takes a const ref, then it shouldn't return a non-const ref to it...
    (And a templated version with perfect forwarding wouldn't solve it: by-val store shouldn't return a copy for "method chaining" :) )

  • Element access is already an overload pair:

    const T& operator [](key_t key) const;
    T& operator [](key_t key);

  • But... I think the problematic version should just be removed, unless there are strong use cases for it -- especially as it can't even return an error!...:

     T& store(key_t slot, const T& cargo) {
     	assert(slot != ERROR);
     	assert(!_is_free(slot));
     	return _slots[slot] = cargo; } // Support method-chaining
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions