Warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11?

I have this code And the compiler gave me this Warning for declaring the object slot1 under the private section in class Moveset. Although it gave me the warning but apparently it didnt affect the programme running. Does it actually affect anything? and what am I doing wrong here? Edit: And what is the diifference … Read more

error C2679: binary ‘<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

You forgot to #include <string> using std::string without including it’s header works on some compilers that indirectly import parts of <string> into their <iostream> or other headers but that’s not standard and shouldn’t be relied upon. Also they often break when you try to output a string since they only included a part of the … Read more

Call to implicitly deleted copy constructor in LLVM

C++11 rules for automatic generation of special members aren’t as simple as you posted them. The most important distinction is that in some cases, the member is implicitly declared, but defined as deleted. That’s what happens in your case. C++11, [class.copy]§11: A defaulted copy/move constructor for a class X is defined as deleted (8.4.3) if … Read more

error: use of deleted function

The error message clearly says that the default constructor has been deleted implicitly. It even says why: the class contains a non-static, const variable, which would not be initialized by the default ctor. Since X::x is const, it must be initialized — but a default ctor wouldn’t normally initialize it (because it’s a POD type). Therefore, to get a … Read more

How do I enable C++11 in gcc?

H2CO3 is right, you can use a makefile with the CXXFLAGS set with -std=c++11 A makefile is a simple text file with instructions about how to compile your program. Create a new file named Makefile (with a capital M). To automatically compile your code just type the make command in a terminal. You may have to install … Read more

push_back vs emplace_back

In addition to what visitor said : The function void emplace_back(Type&& _Val) provided by MSCV10 is non conforming and redundant, because as you noted it is strictly equivalent to push_back(Type&& _Val). But the real C++0x form of emplace_back is really useful: void emplace_back(Args&&…); Instead of taking a value_type it takes a variadic list of arguments, so that means that you can now perfectly … Read more

What is std::move(), and when should it be used?

Wikipedia Page on C++11 R-value references and move constructors In C++11, in addition to copy constructors, objects can have move constructors.(And in addition to copy assignment operators, they have move assignment operators.) The move constructor is used instead of the copy constructor, if the object has type “rvalue-reference” (Type &&). std::move() is a cast that produces … Read more