Skip to content

operator-> for reference_wrapper #94

Open

Description

@denzor200

Why boost::reference_wrapper template class dosn't has operator-> overloading? Is there any objective reason?
It may be useful for some instantiations, like boost::reference_wrapper<Object*> or like boost::reference_wrapper<std::shared_ptr<Object>> to use these without casting

Activity

  1. Lastique commented on Aug 3, 2021

    @Lastique
    Member

    I suppose, the main reason is that reference_wrapper<T> is not intended to be a proxy for T.

  2. pdimov commented on Aug 3, 2021

    @pdimov
    Member

    I suspect you're misunderstanding the request as T* operator-> whereas it's T& operator->.

    reference_wrapper<T> is intended to act as a reference to T and has an implicit conversion operator T&, which enables this. It also has a forwarding operator() because the conversion doesn't work in this case. The request makes sense, the reason for not having operator-> is because nobody brought it up until now.

  3. pdimov commented on Aug 3, 2021

    @pdimov
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions