Questions tagged [c++11]
C++11 is the version of C++ after C++03. This tag should be used (along with the [C++] tag) for questions about C++ features specific to C++11.
c++11
56,743
questions
-4
votes
0
answers
63
views
how often do you use the noexcept or constexpr modifier [closed]
how often do you use the noexcept or constexpr modifier in real work? Scott Myers wrote a lot about the importance of these structures, but why in practice I rarely saw this with my colleagues, share ...
-4
votes
0
answers
89
views
Which C++ string type should I migrate to? [closed]
I see so many options for C++ string types, like:
std::string
std::u16string
std::u8string
CString
Platform::String
wchar_t
char
Narrowing this down a bit, my 3 options seem to be:
std::string - ...
-1
votes
1
answer
55
views
External Data Structure Used in Custom Comparison Function in C++ [duplicate]
I have array of numbers and I have to sort them based on there frequency in ascending order
and if both numbers are same then sort them in decreasing order
what I did was I create unordered_map and ...
1
vote
3
answers
127
views
Behaviour of std::is_sorted function in C++
Consider the following C++ program which checks whether the given array is sorted or not.
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
std::vector<...
-3
votes
1
answer
71
views
count the maximum number of triangles made up of a sequence of numbers Two triangles are called the same if they have 3 pairs of sides equally [closed]
WE HAVE A ARRAY: 2 3 3 4 4 4 6 6 6 6
Maximum number of triangles formed: 12
BECAUSE:
(4, 4, 4) 4) (4, 4, 2) (4, 4, 3) (4, 4, 6) (6, 6,
2) (6, 6, 3) (6, 6, 4) (2, 3, 4) (3, 4, 6)
(6, 6, 6) (3, 3, 2) (3,...
-1
votes
0
answers
97
views
why std::move(std::vector<int>) does not move [duplicate]
I'm really confused cause of C++ having so many "unspecified states". In the code below, I'm trying to move std::vector to a set(&&) function, but the output seems like it's not ...
0
votes
0
answers
28
views
Why is variadic template get error of "no matching function call"
Here is the repro:
#include <iostream>
template <typename T, typename ...Args>
inline void HashCombine(std::size_t& seed, const T& v, const Args& ... args)
{
seed ^= std::...
-1
votes
0
answers
30
views
What is the difference in using '?' inside and outside a group? [duplicate]
I am trying to match strings such as the following.
Valid
12345678
12-34-56-87
Invalid
1-234-56-78
12-45-7810
#include<regex>
using namespace std;
int main() {
string s = "";...
-1
votes
2
answers
56
views
C++ Rectangle 2D Array with numbers beside the rectangle
I've been trying to make a 2D array of rectangle, and i want the number of index x to printed beside the rectangle and index y to be printed below the rectangle..
Here is my code..
int height, width;
...
0
votes
3
answers
70
views
difficulty to understand the code, and maybe the concept itself (recursion problem)
this code below is from Grokking Algorithms book that is an exercise for the functional programming/recursion and an application for the D&C concept. the function finds the maximum number in a ...
-2
votes
0
answers
75
views
Undefined reference to std::string while linking, but the header doesn't seem to be the problem [duplicate]
I am translating a program that was written in C to C++. It was as easy as changing the suffix to the file and modifying some compiler flags. Before using actual C++ features, it compiled perfectly.
...
1
vote
1
answer
118
views
Two almost similar multithreaded code have very different running time
i am having a strange problem for C++ multithreaded programs.
i wrote the first code and was not seeing any performance improvement over single threaded code.
i kept on experimenting with shifting the ...
1
vote
2
answers
109
views
Why exception can not be caught on windows by msvc but on Linux by GCC [duplicate]
The same files on Windows and Linux as follow:
std_exp.cpp
#include <iostream>
#include <string>
#include <stdexcept>
using namespace std;
int main() {
try {
std::...
-3
votes
1
answer
71
views
Understanding usage of std::for_each with structs [duplicate]
I am trying to understand how below code works, from cpp reference website:
std::vector<int> v{3, -4, 2, -8, 15, 267};
struct Sum
{
void operator()(int n) { sum += n; }
int sum {0};
};
...
0
votes
2
answers
62
views
c++ 'const' in multi-file
In C++ Primer, it tells me that I should modify all const variables with 'extern'. However, when I tried that in DevC++ 5.11 with C++11, I found that it was not necessary.
//main.cpp
#include <...