Skip to main content

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.

0 votes
0 answers
19 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 = "";...
Aadhar Jain's user avatar
0 votes
1 answer
40 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; ...
ken's user avatar
  • 1
-1 votes
0 answers
62 views

FSM with templates and pointers [duplicate]

Hi I'm trying to make a FSM Finite State Machine in c++ with pointers and templates. I want to simplify my code and get access to the variable of the State controller inheritted or the Game Screen ...
Bersere's user avatar
0 votes
3 answers
58 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 ...
Ahmed Salah's user avatar
-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. ...
Bestemmie's user avatar
1 vote
1 answer
116 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 ...
programmer of c's user avatar
1 vote
2 answers
103 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::...
Monhde Sau Hung's user avatar
-3 votes
1 answer
69 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}; }; ...
barribow's user avatar
  • 111
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 <...
zzz's user avatar
  • 1
0 votes
0 answers
61 views

Templating CUDA

CUDA supports templates and that is nice, I have however problem with interplay with C++. Let's say I have functions template <typename T> void CUDAZeroPad2D(dim3 threads, ...
VojtaK's user avatar
  • 610
0 votes
1 answer
25 views

--trace-children-skip option is not having any impact with Valgrind

I have a run.sh with: ./opt/exm/bin/exm_daemon exm_daemon spawns many process. I run valgrind with options: sudo valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --trace-children=...
noob-sys-dev's user avatar
0 votes
0 answers
59 views

Right memory_order to react on atomic increment changes in other thread?

Consider such code: #include <atomic> #include <thread> bool read_from_network() noexcept; void write_to_network() noexcept; int main() { std::atomic<size_t> work_counter; std:...
user1244932's user avatar
  • 7,932
0 votes
1 answer
61 views

Guarding tests against exit/death

I'm using googletest to test multi-threading code with std::thread. In broken code, it often happens that a std::thread is destroyed before the thread has joined, causing a program termination. ...
Hendrik's user avatar
  • 567
4 votes
2 answers
116 views

Idiomatic ways of using tuples and std::tie

I am trying to implement the modular multiplicative inverse using the extended Euclidean algorithm in C++. In Python, the code for this is concise and idiomatic, using tuple unpacking: def inv_modulo(...
João Areias's user avatar
  • 1,338
1 vote
1 answer
63 views

C++ function dispatch based on user defined input type category (C++11/14 friendly)

I want to dispatch functions based on user defined "tag" of my input types. For example, I defined a tag called SomeSpecificObjectType and in class Object I mark this class as a ...
Xiyang Liu's user avatar

15 30 50 per page
1
2 3 4 5
3783