Skip to main content
7 votes
1 answer
225 views

Consider the following example #include <utility> int main() { int i = 0; int& r = i; std::pair<int&, int> p{r, i}; int& ret = std::get<int&>(...
syby119's user avatar
  • 145
1 vote
0 answers
130 views

If I have a vector<std::pair<std::pair<int, int>, std::pair<int, int>>>, what would you suggest as the most concise method to iterate over them, having access to all four ...
Mampac's user avatar
  • 351
0 votes
1 answer
89 views

I have a vector container, typename is std::pair, but i found there are many construct/deconstruct operation when add element. Here is a demo code: #include <iostream> #include <vector> ...
kevin h's user avatar
  • 143
5 votes
1 answer
292 views

I'd like to be able to decompose a structured binding, of lets say, std::pair<T, U> into a non-const variable and a const variable: E.g. std::pair<int, int> anExamplePair = std::make_pair(...
HarryP2023's user avatar
-1 votes
1 answer
56 views

When populating an unordered map of int pairs, creating a std::pair object with a static const class member seems to cause an undefined symbol error, but only in the std::pair constructor call. If I ...
Jeff H's user avatar
  • 1
-1 votes
2 answers
67 views

I have to make a HashMap of point and Array-list. point is nothing but the pair of x and y in x-y plain. then i want to store all student's roll no. which are there at that specific point. as we don't ...
jayant rajput's user avatar
3 votes
2 answers
96 views

Code #include <iostream> #include <unordered_map> #include <utility> using namespace std; struct Foo { Foo(const int value) : val(value) { cout << "Foo(int), ...
Rebased's user avatar
  • 51
3 votes
1 answer
63 views

Apologies for the awkwardly worded question. My uncertainty is based on a situation that can roughly be reduced to the following scenaio. I have a Foo class, and I'd like a std::pair<int, Foo> ...
11thHeaven's user avatar
2 votes
2 answers
154 views

Here is a simplified code: https://godbolt.org/z/EnE76xMrP The pImpl will contain a mutex member which make the pImpl neither copyable nor movable. But the Foo class has unique_ptr of pImpl as member ...
omarekik's user avatar
0 votes
1 answer
66 views

Suppose we have two structs: struct FIRST{ int a=0; int b=0; FIRST(int a, int b): a(a), b(b){} }; struct SECOND{ int c=0; int d=0; SECOND(int c, int d): c(c), d(d){} }; And we ...
MPEI_stud's user avatar
  • 135
0 votes
2 answers
113 views

Let's say the elements of the vector of pairs are 1, 0 2, 0 1, 2 2, 4 4, 0 5, 0 The output should be 1, 2 2, 4 4, 0 5, 0 In the above example, the pairs {1, 0}, and {1, 2} are replaced by the pair {...
SHOEBILL's user avatar
1 vote
1 answer
704 views

Note: Please don't close the question just because the root cause was due to comma operator. The value of the question was to let the community understand the failure of: std::vector<std::pair<...
cpp's user avatar
  • 331
0 votes
2 answers
129 views

I'm writing a program containing many long for-loops, and I want to add a progress bar indicator to each. To do this, I wrote struct ProgressBar to accomplish this. The interface is as follows: struct ...
Christopher Miller's user avatar
4 votes
2 answers
118 views

This question may not have the best title but here is the code that will explain what I am trying to ask. This code runs and prints "lvalue" but If I remove const from MyPair's first type, ...
armques's user avatar
  • 127
4 votes
1 answer
284 views

Only 5 tags are allowed, but please, take it as c++20 and c++23 are in the list too, because I'd like to know about those standards as well, in case something has changed since c++17. Is the order of ...
Enlico's user avatar
  • 30.5k

15 30 50 per page
1
2 3 4 5
53