Skip to main content

All Questions

Tagged with
0 votes
3 answers
111 views

Can find_if be used to find a key in std::map/std::unordered_map?

This is a simple program consisting of adding an element into the std::unordered_map. But before it's added, first check if the key already exists, if it does then don't add it. My problem is that ...
tadm123's user avatar
  • 8,698
1 vote
1 answer
70 views

How to find an element in a vector of class objects, based on one of the class members, and delete it

I have a vector of classes. Each class has two member variables, a name (string) and time spent working (integer). My goal is simply delete an element of an array that contains a specific name. I know ...
tadm123's user avatar
  • 8,698
-2 votes
1 answer
176 views

Iterator with find() in c++

I want to know how to get the position of the result when I use the find() command. My code have the command: vector<int>::iterator result = find(list_of_number.begin(), list_of_number.end(), ...
Hitomi Arashi's user avatar
0 votes
1 answer
1k views

C++20 contains and get value VS find

I understand that some containers in C++, such as map or unordered_map, have a mechanism that allows accessing values directly if you have the key. I'm not sure if this is entirely correct... The ...
MillhioreBT's user avatar
-1 votes
1 answer
246 views

How can I find if a substring is present in a string or not without using find() function?

How can I find if a substring is present in a string or not without using find() function? Is there any efficient way to find the substring than using find() function? ` #include <bits/stdc++.h> ...
Chaitanya Rustagi's user avatar
0 votes
1 answer
476 views

error C2676 binary '==': 'block' does not define this operator or a conversion to a type acceptable to the predefined operator

#include <iostream> #include <vector> using namespace std; class block { public: int x, y; block(int in_x = 0, int in_y = 0) { x = in_x; y = in_y; } int ...
easy e g's's user avatar
0 votes
0 answers
166 views

Search a pair in unordered_set of pairs from first element in C++

I want to erase the pair: (x,"whatever"), and i want: 1)find an iterator position of the pair with x as first element 2)after that erase the element in the position of the iterator typedef ...
dmiw's user avatar
  • 1
0 votes
1 answer
44 views

How to start fresh on a while / do-while loop?

using namespace std; int main() { char repeat; do { string str; cout << "What is your first and last name? " << endl; getline(cin, str); ...
Puggy's user avatar
  • 107
0 votes
3 answers
794 views

Find all substring in a given string c++

I've got a problem with a program which finds all substring in a given string. I've tried to make variable "found", which would contain a position of a previously found substring and then ...
Michał Matusik's user avatar
0 votes
2 answers
489 views

Time complexity for std::find_if() using set in C++

What is time complexity for std::find_if() function using std::set in C++? Consider we have the following example: auto cmp = [&](const pair<int, set<int>>& a , const pair<int, ...
Олег Оратовский's user avatar
0 votes
1 answer
186 views

Is there a find algorithm for Google Protocol Buffers (Protobuf)?

Is there a find algorithm for Google Protobuf array objects? eg, if I have a protobuf with a repeated field such as message MyProto { repeated int32 intArray = 1; } how can I find a particular ...
FreelanceConsultant's user avatar
1 vote
2 answers
100 views

How can i properly use the .find() function from set in C++?

Here is the struct for 'point' struct point { double x; double y; }; and here is the function that produces an error, there is an issue with my use of .find() as show in the pic below. When I ...
Jack Hermanson's user avatar
0 votes
0 answers
29 views

The use of std::map find is throwing compiler error C2675 and I can't figure out why [duplicate]

Why is my find failing to compile for the class below? Error reads: Severity Code Description Project File Line Suppression State Error C2675 unary '++': '_Iter' does not define this ...
Robert Fayz's user avatar
0 votes
1 answer
478 views

C++, Find out if a string contains a substring?

I don't know how to use the find() function to check if a string contains a substring, then the program should print out all Words, and "Contains" if Sentence contains at least one of them. ...
user avatar
0 votes
1 answer
311 views

Finding the last index of the first substring found in a string

I was looking through a lot of the solutions on here and there doesn't seem to be anything that does this with a built-in c++ method. std::string str = "Hey I'm John, John's friend"; int ...
Pal's user avatar
  • 47

15 30 50 per page
1
2 3 4 5
40