Use of rvalue reference members?

后端 未结 4 1026
离开以前
离开以前 2021-01-30 06:52

I was wondering what use an rvalue reference member has

class A {
  // ...
  // Is this one useful?
  Foo &&f;
};

Does it have any bene

4条回答
  •  我在风中等你
    2021-01-30 07:31

    Just thinking out loud here, but wouldn't it have a use in functors? The constructor is often used for "currying", binding some parameters in advance, before the actual function call.

    So in this context, the class member is just a staging ground (or a manually implemented closure) for the upcoming function call, and I see no reason why a rvalue reference wouldn't be meaningful there.

    But in "regular" non-functor classes, I don't see much point.

提交回复
热议问题