Category "c++11"

When is std::weak_ptr useful?

I started studying smart pointers of C++11 and I don't see any useful use of std::weak_ptr. Can someone tell me when std::weak_ptr is useful/necessary?

How do I activate C++ 11 in CMake?

When I try to run a CMake generated makefile to compile my program, I get the error that range based for loops are not supported in C++ 98 mode. I tried a

How do I activate C++ 11 in CMake?

When I try to run a CMake generated makefile to compile my program, I get the error that range based for loops are not supported in C++ 98 mode. I tried a

How is the UI of terminal texteditors implemented?

Terminal texteditors like emacs,vim,joe or even nano have the ability to display arbitrary UI elements inside a command line without completely rewriting the wh

How to get configuration.h from configuration.h.in in OpenSSL?

I am working with the OpenSSL library for C++. I used this library in another project and it worked great. I carried it over to another project today and I'm ha

How to check if a std::thread is still running?

How can I check if a std::thread is still running (in a platform independent way)? It lacks a timed_join() method and joinable() is not meant for that. I thoug

How to get on top-level const pointer using "auto"?

In short words: Per C++ Primer, pg 69, "auto": "If we want the deduced type to have a top-level const, we must say so explicitly". I would get an top-level

Can I list-initialize a vector of move-only type?

If I pass the following code through my GCC 4.7 snapshot, it tries to copy the unique_ptrs into the vector. #include <vector> #include <memory> in

How do I call ::std::make_shared on a class with only protected or private constructors?

I have this code that doesn't work, but I think the intent is clear: testmakeshared.cpp #include <memory> class A { public: static ::std::shared_pt

c++11/regex - search for exact string, escape [duplicate]

Say you have a string which is provided by the user. It can contain any kind of character. Examples are: std::string s1{"hello world"); std::

What is the no-undefined-behavior way of deserializing an object from a byte array in C++11 (or later)?

To overcome alignment issues, I need to memcpy into a temporary. What type should that temporary be? gcc complains that the following reinterpret_cast will br

std::regex escape special characters for use in regex

I'm string to create a std::regex(__FILE__) as part of a unit test which checks some exception output that prints the file name. On Windows it fails with:

Get std::set comparison as function parameter / complemet of a set without universal set

I have this .cpp file and I have to write the methods set_union, subset, complement, and contains. My two problem is first: How can I have a complement without

How do I use a custom deleter with a std::unique_ptr member?

I have a class with a unique_ptr member. class Foo { private: std::unique_ptr<Bar> bar; ... }; The Bar is a third party class that has a create

Exact difference between rvalue and lvalue

While I was reading http://thbecker.net/articles/rvalue_references/section_01.html, I got following snippiest. // lvalues: // int i = 42; i = 43; // ok, i is an

Outputting Date and Time in C++ using std::chrono

I have been upgrading some old code and have been trying to update to c++11 where possible. The following code is how I used to display the time and date in my

return type of operator+= while overloading

I have gone through some examples in the internet for operator overloading where the return type of operator+= is T&. Since we can't chain += like T a = b =

How to iterate an unordered_set from the end to the begin

I want to iterate an unordered_set from the end to the begin: unordered_set<Expression*> BlocExpressions; for(auto it=BlocExpressions.end(); it != BlocEx