Category "c++11"

Is it safe to init a std::unique_ptr from a local raw pointer?

I know it's unwise to do so with a std::shared_ptr. But what about std::unique_ptr? E.g. : class A { public: void do_something() { } }; std::vector<std::

How can I generate a tuple of N type T's?

I want to be able to write generate_tuple_type<int, 3> which would internally have a type alias type which would be std::tuple<int, int, int> in thi

How does const auto and auto const apply to pointers?

I was try out some code and am wondering how the const qualifier in C++ applies to pointer types when using auto. int main() { int foo = 1; int bar = 2;

print the unordered map values when key value is given as input

I have written the code to read the string values and mapped as key and value. Now I am facing issue in printing the values, if we have given key value as input

C++ E0147 declaration is incompatible with static object

Websource.hpp #ifndef WEBSOURCE_HPP #define WEBSOURCE_HPP #pragma once class Colour { public: unsigned char _ucRed; unsigned char _ucGreen; unsign

Modern pattern to write custom ostream operator

Typically, in C++, we used to define a custom ostream operator<< this way: class A { int impl_; friend std::ostream& operator<<(std::ost

const& , & and && specifiers for member functions in C++

Recently I was reading through the API of boost::optional and came across the lines: T const& operator *() const& ; T& operator *() & ; T

How to specify -std=c++11 option in bazel BUILD file?

How to add this option into a target description section? Thanks.

Why isn't abs constexpr?

In <cinttypes>, since C++11, there are the following two overloads: std::intmax_t abs( std::intmax_t n ); std::intmax_t imaxabs( std::intmax_t n ); Why

When does instantiation happens for explicit instantiation of a function template

Hi i am learning about explicit instantiation. And so reading different examples but in one example have some doubts. The example is given below and i have 2 do

The implementation of std::forward

I'm reading Overview of the New C++ (C++11/14) (PDF only), at Slide 288 it gives an implementation of std::forward: template<typename T> //

Is it possible to use std::string in a constexpr?

Using C++11, Ubuntu 14.04, GCC default toolchain. This code fails: constexpr std::string constString = "constString"; error: the type ‘const string

What is the proper use of CMake FindThreads with modern C++?

The source for the CMake (https://github.com/Kitware/CMake/blob/master/Modules/FindThreads.cmake) claims the following about the "FindThreads" functionality:

What is the difference between std::reference_wrapper and a simple pointer?

Why is there a need to have std::reference_wrapper? Where should it be used? How is it different from a simple pointer? How its performance compares to a simple

How to move elements from a set to a vector efficiently?

I have a std::set<vector<int>> from which I would like to move (not copy) elements to a std::vector<vector<int>>. How do I do this? I t

Move-only version of std::function

Because std::function is copyable, the standard requires that callables used to construct it also be copyable: n337 (20.8.11.2.1) template<class F> funct

How does #include <bits/stdc++.h> work in C++? [duplicate]

I have read from a codeforces blog that if we add #include <bits/stdc++.h> in a C++ program then there is no need to include any other h

Algorithm to convert std::stack to std::string in C++ STL

In below C++ program I'm deleting a previous character considering '#' as a backspace character. I have used stack to build the string. Is there any C++ STL alg

‘is_trivially_copyable’ is not a member of ‘std’

My gcc version is 4.8.3 20140624. I can use is_pod, is_trivial, is_standard_layout, but fail when trying is_trivially_copyable, is_constructible and is_default_

Why the boost msm calls the guard twice?

I'm implementing a state machine as the following diagram state machine diagram I trigger "event1" and "event2" to the state machine, when "event1" triggered,