Does extern template prevent inlining of functions?

The idea behind extern templates is to make explicit template instantiations more useful. As you know, in C++03, you can explicitly instantiate a template using this syntax: template class SomeTemplateClass<int>; template void foo<bool>(); This tells the compiler to instantiate the template in the current translation unit. However, this doesn’t stop implicit instantiations from happening: the … Read more

Should I return an rvalue reference parameter by rvalue reference?

There’s no right answer, but returning by value is safer. I have read several questions on SO relating to returning rvalue references, and have come to the conclusion that this is bad practice. Returning a reference to a parameter foists a contract upon the caller that either The parameter cannot be a temporary (which is … Read more

Most efficient standard-compliant way of reinterpreting int as float

Afaik, there are only two approaches that are compliant with strict aliasing rules: memcpy() and cast to char* with copying. All others read a float from memory that belongs to an uint32_t, and the compiler is allowed to perform the read before the write to that memory location. It might even optimize away the write … Read more

C++11 full support on Eclipse [closed]

Eclipse works with C+11 support (Indexer and such) just fine: both Juno and Kepler. The thing is that you have to let Eclipse know that you are going to compile with C++11 support. This is done by providing additional flag -std=c++11 to CDT GCC Builtin Compiler Settings in C/C++ -> Build -> Settings -> Discovery … Read more

Is it useless to declare a local variable as rvalue-reference, e.g. T&& r = move(v)?

No, AnyTypeMovable&& r = move(v); here is not useful at all. Consider the following code: #include <iostream> #include <vector> class MyMovableType { int i; public: MyMovableType(int val): i(val){} MyMovableType(MyMovableType&& r) { this->i = r.i; r.i = -1; } MyMovableType(const MyMovableType& r){ this->i = r.i; } int getVal(){ return i; } }; int main() { std::vector<MyMovableType> … Read more

Why does reallocating a vector copy instead of moving the elements? [duplicate]

The short answer is that I think @BenVoigt is basically correct. In the description of reserve (§23.3.6.3/2), it says: If an exception is thrown other than by the move constructor of a non-CopyInsertable type, there are no effects. [And the description of resize in §23.3.6.3/12 requires the same.] This means that if T is CopyInsertable, … Read more

How can C++ compilers support C++11 atomic, but not support C++11 memory model

One of the issues is the definition of “memory location”, that allows (and forces the compiler to support) locking different structure members by different locks. There is a discussion about a RL problem caused by this. Basically the issue is that having a struct defined like this: struct x { long a; unsigned int b1; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)