Calling the base class move ctor [C ++ 0x]

What is the correct way to call the move ctor base class?

this (works in MSVC2010, but not in CBuilder2010):

struct Foo
{
    Foo(Foo&& other) { }
};

struct Bar : public Foo
{
    Bar(Bar&& other) : Foo((Foo&&)other) { }
};

or (works in CBuilder2010, but not in MSVC2010):

struct Foo
{
    Foo(Foo&& other) { }
};

struct Bar : public Foo
{
    Bar(Bar&& other) : Foo(&other) { }
};

or are they both wrong? If so, what is the correct way (in terms of what is specified in C ++ 0x standards)?

Note. I cannot figure out how to make it work in CBuilderXE (both versions do not work).

+3
source share
2 answers

The first option seems logical, although I would call it std::forward<Bar>(other).

I have no idea why CBuilder thinks type &otheris equal Bar&&, not Bar*.

, , , , rvalue , rvalue, std::forward, rvaluness ( ), , : Foo(other), ' , .

( ) , ( FCD).

+3

, , , . std::forward<Bar>(other) - - , .

0

Source: https://habr.com/ru/post/1772443/


All Articles