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
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
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_
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,
I am trying to learn std::function and here's my code: #include <iostream> #include <functional> struct Foo { void print_add(int i){ st
I'm constructing an object that takes a std::vector<std::unique_ptr<A> > as an argument. The constructor is defined like this class B { std::ve
Why this cause undefined behavior? #include <iostream> #include <thread> #include <vector> std::vector<std::thread> threads(3); void
For ex, unordered_set<int> s ; s.insert(100); How do I get value 100 from s? From http://www.cplusplus.com/reference/unordered_set/unordered_set/begin
It is necessary to me to use std::function but I don't know what the following syntax means. std::function<void()> f_name = []() { FNAME(); }; What is
I'm a beginner for c++. I wrote a program to extract data from one DB and store those data to another DB. I just want to add multiple threads to speed up the pr
Consider the following auto a = 10; When does the compiler know that a is an int, at compile time or at run-time? If it deduces the type at run-time, will it n
Can I query an ostream object about whether or not it has been written to? For an ostringstream, one could use if(!myOssObject.str().empty()) What about the
Namespaces are in many was like classes with no constructors, no destructors, no inheritance, final, and only static methods and members. After all, this kind o
I have a class containing an enum class. class Shader { public: enum class Type { Vertex = GL_VERTEX_SHADER, Geometry = GL_GEOMETRY_SHADE
It's a question from C++ Primer Chapter 16.2.3 (question 16.41): Write a version of sum with a return type that is guaranteed to be large enough to hold t
Imagine you have a simple matrix class template <typename T = double> class Matrix { T* data; size_t row, col; public: Matrix(size_t m, size_t n
Lines from Anthony William book: std::launch::deferred indicates that the function call is to be deferred until either wait() or get() is called on the fu
What's the difference between constexpr and const? When can I use only one of them? When can I use both and how should I choose one?
Is there a difference between the following definitions? const double PI = 3.141592653589793; constexpr double PI = 3.141592653589793; If not, which styl
I know in C++11 they added the feature to initialize a variable to zero as such double number = {}; // number = 0 int data{}; // data = 0 Is there a simila