Category "c++11"

Subtraction of two nullptr values guaranteed to be zero?

Is it guaranteed by the C++ standard that if I have two pointers of the same type whose value is equal to nullptr, that the difference between those pointers is

Subtraction of two nullptr values guaranteed to be zero?

Is it guaranteed by the C++ standard that if I have two pointers of the same type whose value is equal to nullptr, that the difference between those pointers is

Get name of type behind type alias in function template

I'm working with Visual Studio 2013. When I need to know what types the compiler deduced for my template parameters, I usually trigger a compiler error like thi

Object not declared in this scope error in cpp?

I'm getting error SPIGtestMain.cpp:"MockObj not declared in this scope" though I've declared it globally in with extern keyword in SPIGtestMain.cpp file. SPIG

Object not declared in this scope error in cpp?

I'm getting error SPIGtestMain.cpp:"MockObj not declared in this scope" though I've declared it globally in with extern keyword in SPIGtestMain.cpp file. SPIG

create json object for vector<bool> using nlohman json

I want to convert a vector<bool> vec = {true, false,true} to json object using nlohman json lib to send through restapi. I expect the converted json objec

How to check a type has constexpr constructor

I want my class use another implementation for types don't have constexpr constructor. like this: template <typename A> class foo { public: // if A h

Member specialization does not match any template declaration

The code below compiles except for the lines template <> std::map<std::string, std::function<Goo*(Foo*)>>& Factory::getMap<Goo, Foo*>

How to find the count of sub numbers of size k which divide the number

Given a number n Find the count of the sub numbers of size x in a number num which divides num. For example, if the number is 250 and x=2 the answer will be 2 a

Calling a protected function from instance inside a derived class

Currently, I am trying to solve the following situation. I have a classB which contains some objects from a classA. Each classA has a function foo which needs t

Overloading the assignment operator= doesn't work for anything except the implicit object passed in c++

The comparison in the assignment operator works as expected, but when I try to use a temp variable and load then return that, all it returns is the defaults. De

Why is conversion from string constant to 'char*' valid in C but invalid in C++

The C++11 Standard (ISO/IEC 14882:2011) says in § C.1.1: char* p = "abc"; // valid in C, invalid in C++ For the C++ it's OK as a pointer to a String Lit

How can I divide the Eigen::matrix by Eigen::vector?

following is my code. Eigen::Matrix3d first_rotation = firstPoint.q.matrix(); Eigen::Vector3d first_trans= firstPoint.t; for(auto &iter:in_point

Defining an atomic<> as a static variable inside a function

C++11 mandates that static variables inside a function are atomically initialized for the first run of the function. The only way to do that efficiently is doub

Identifier "Return" is undefined in gtest?

SPIGtestMain.cpp #include "gtest/gtest.h" #include "gmock/gmock.h" TEST_F(GivenANewSPI,WhenDemoIsCalled_TheComponentGetsVal) { unsigned char const *Ptr;

Question about the declaration about the aliasing constructor for `std::shared_ptr`

I think the 8th constructor of the std::shared_ptr<T> should be decalared as template< class T, class Y > shared_ptr<T>( const shared_ptr<Y

BOOST request sending JSON data

I want to transfer json data into request of json boost in cpp. If i take json in boost int outer=2; value data = { {"dia",outer}, {"sleep_tim

Initializing container of unique_ptrs from initializer list fails with GCC 4.7

I am trying to initialise an std::vector<std::unique_ptr<std::string>> in a way that is equivalent to an example from Bjarne Stroustrup's C++11 FAQ:

Brace Initialize struct with virtual functions

Brace initialization struct A { int a; int b; void foo(){} }; A a{1, 2}; It works fine. Bu

I need a function to delete certain characters from a char array in c++ without using any index

for example: if the user enters : ( 23+22+43) I want the function to do exactly the following : for(int i =0; i <strlen(x);i ++) { if (x[i]=='+') {