Questions tagged [std-pair]

A std::pair is an ordered, heterogeneous sequence of exactly two objects (it is a special case of std::tuple).

std::pair is a part of the C++ Standard Library, defined in the header <utility>.

Reference: https://en.cppreference.com/w/cpp/utility/pair

776 questions
-1
votes
2 answers

Algorithm Error: Argument cannot covert 1 from pair

In this assignment, I'm making an application where a user inputs a phone number whether it be letters or not. I've tried using the const on maps or vector to see if it fixes the problem, but I think it just created more errors. Here's the code that…
-1
votes
1 answer

How to make map.find() function with a std::pair

I'm getting this error trying to do map.find(10,20) does anyonw knows how to do it Error (active) E0304 no instance of overloaded function "std::map<_Kty, _Ty, _Pr, _Alloc>::find [with _Kty=std::pair, _Ty=std::tuple,…
-1
votes
1 answer

Find int in Vector of pairs vector >> using find_if

My data structure is: vector >> accVec; where the int is the bank account number. My goal is to check if the account number input by the user matches any int within any pair in the accVec vector. In main, I'm…
ionics
  • 17
  • 2
-1
votes
1 answer

Return value optimization with std::pair

I am currently quite puzzled with C++17`s guaranteed RVO and its implications. I understand that for NRVO to kick in, I need to make sure that to return one and the same instance of an object through all possible return path of the function and…
CD86
  • 979
  • 10
  • 27
-1
votes
1 answer

pair vs vector (2) C++

Why create a function like boost and std minmax that returns a pair, both of the same type. when you could return a vector and have the possibility of access to them with index. If: vectores need .size()..., pair<> are exactly 2 elements... means…
Moises Rojo
  • 371
  • 2
  • 14
-1
votes
1 answer

CGAL How to save std::vector points into .xyz file?

I'm new to C++ and I'm not familiar with vector and pair. I'm working on CGAL, and I want to save std::vector points into a .xyz file, but the provided example in CGAL doc uses different type std::pair in order to save. Could…
rathaROG
  • 31
  • 9
-1
votes
3 answers

STL template function to return a pair

I'm trying to write a function that returns a pair of values from an STL container. template std::pair getMinMax(T &container) { auto min = *(container.begin()); auto max =…
user1211030
  • 2,680
  • 2
  • 19
  • 22
-1
votes
1 answer

traverse in vector > >

I came across a situation that I couldn't explain why. I have a vector > > parent that indicates parent of a specific cell. I have following code: // (1, 0), (1, 2), (1, 2) // (1, 2), (-1, -1), (1, 2) // (-1, -1), (2, 1),…
ZigZagZebra
  • 1,349
  • 3
  • 14
  • 25
-1
votes
1 answer

checking if given vector contains already elements of pair in c++

let us suppose have following pairs 0 -1 0 -2 0 -3 1- 2 2 -3 3- 4 2 -4 4- 5 5 -6 i would like to insert those pairs into vector , so that i should have each element only one times , for instance start with empty vector : 0-1 is inserted now…
user466534
-1
votes
1 answer

C++ Searching object in nested pair of an std::set

I have an STL set of type: std::set< std::pair< double, std::pair< unsigned, vector< unsigned > > > > X I know I could make things simpler by changing my data structure but that's not an option here for me. How can I search for an element of type…
-1
votes
1 answer

Splitting a pair datatype into its elements in CGAL

I'm a newbie to CGAL and also C++ (Actually I'm a C developer and just moved to C++ in order to use CGAL). I found that by mixing 2-3 examples provided in the CGAL documentation, I can do what I want with CGAL. If I run each code separately and take…
Alibemz
  • 115
  • 1
  • 7
-1
votes
1 answer

Vector that can hold three data types using std::pair

vector< pair >, string> v; Also mention how to access them using 'first' and second'. Is it even possible to do this or is "union" or "structure" the only way to create vector that can hold more than two data types?
theavatar
  • 115
  • 1
  • 9
-1
votes
3 answers

Const Conversion in std::pair

How can I convert std::pair to std::pair without actually making a new pair? I tried using static_cast as below: static_cast>(curr->valPair) curr->valPair - is returning…
Mayank Jain
  • 2,504
  • 9
  • 33
  • 52
-1
votes
1 answer

Use Vector with Pair

I have code kruskal's algorithm(MST) and use vector of pairs like this vector > > v; I want to add wight and make source, destination pair like this v.push_back(make_pair(wight,make_pair(src,des))); and…
Vijay Sharma
  • 342
  • 4
  • 15
-1
votes
1 answer

Making map double pair

I have class: template class CRoute { public: CRoute& Add(const _T & u1 , const _T & u2 , const _E & e); ... private: map < _T, vector> > graf; }; Add function have to assign elements to…
Dmitriy
  • 77
  • 1
  • 1
  • 5