I have an unfortunate problem. My GCC 4.6.3 compiler refuses to compile my move constructor. Exchanging line 6 in the example with "MemoryBlock(const MemoryBlock & other)" would make it compile, but not using the below move constructor declaration. Seems like the compiler does not know C+11, even though it should using 4.6.3. Right?
#include <cstddef>
class MemoryBlock
{
public:
MemoryBlock(MemoryBlock && other) //<----------- RAD 6.
{
}
private:
size_t _length; // The length of the resource.
int* _data; // The resource.
};
int main() {
}
Compiler output:
prog.cpp:6:28: error: expected ‘,’ or ‘...’ before ‘&&’ token
prog.cpp:6:36: error: invalid constructor; you probably meant ‘MemoryBlock (const MemoryBlock&)’
make: * [slask] Error 1
GCC version:
g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 (Kör från labbsal i skolan)
makefile:
%.out: %.cpp
g++ -g -W -Wall -std=c++0x $*.cpp -o $*.out;
CXXFLAGS
and letting the default rules do their job. – juanchopanza