Category "c++11"

How to apply Shamir's Secret Sharing on strings passwords

I was trying to write a simple code to generate and obtain passwords using Shamir's secret sharing method. My question is: How can I apply this to string passwo

do sequentially-consistent atomic loads (load-load pair) form an inter-thread synchronisation point?

I am trying to understand what does sequentially-consistent ordering mean for loads. Consider this artificial example: #include <atomic> #include <thr

How to avoid the need to specify deleter for std::shared_ptr every time it's constructed or reset?

std::unique_ptr has 2 template parameters, the second of which is the deleter to be used. Thanks to this fact, one can easily alias a unique_ptr to a type, whic

Why do std::stof, std::stod, and std::stold handle errors with exceptions?

What is the rationale for why std::stof, std::stod, and std::stold throw exceptions? http://en.cppreference.com/w/cpp/string/basic_string/stof Input errors are

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