2020欧洲杯时间表

Questions tagged [stl]

2020欧洲杯时间表 The Standard Template Library, or STL, is a C++ library of generic containers, iterators, algorithms, and function objects. When C++ was standardised, large parts of the STL were adopted into the Standard Library, and these parts in the Standard Library are also sometimes erroneously referred to collectively as "the STL".

Filter by
Sorted by
Tagged with
0
votes
1answer
10 views

I have a question about std::priority_queue

struct Event { int ObjectID{}; EnumOp Op{}; high_resolution_clock::time_point WakeUpTime{}; int TargetID{}; constexpr bool operator>(const Event& rhs) const { ...
1
vote
2answers
36 views

Can't construct from std::initializer_list when privately inheriting from std::array

I'm trying to make a wrapper of std::array to perform boundary checks as suggested by this answer. This is the code I have: template <typename T, size_t N> class Array : private std::array<T,...
0
votes
1answer
37 views

What “operator()” means in overloading operators method, used in priority_queue (STL) as comparator in C++?

I've read in a book of c++ algorithms about overloading operators and I have a problem understanding how overloading operator works in that case. This is the sequence of code: struct cmp { bool ...
-1
votes
0answers
38 views

How could you do a function on a certain area of a string in c++?

With the ctime function, you can store the current time and day in a string. I also have a date class that accepts an integer value of the year, day and month in the parameters. If I were to store the ...
1
vote
0answers
30 views

Use of predicate in count_if function [closed]

I have the following code... #include <bits/stdc++.h> using namespace std; int main() { vector<int> v = {1,2,3,4,5}; int evens = count_if(v.begin(),v.end(),[](int a) {return !(a&...
2
votes
4answers
64 views

Does declaring a vector with size offer any improvements over using push_back in C++

Let us say we know the size of a vector we will be needing, (say 'n'). Does using vector<int> Array(n); offer any improvements over using Array.push_back(element) one by one? Which is ...
-1
votes
0answers
17 views

What is equivalent QTime::fromString(“12:01”, “h:m”) in STL?

In some situations i cant use Qt and i only have C++ STL, how can i do something like this: auto time{ QTime::fromString("2:12", "h:m") }; if (time < QTime::current_time()) { qDebug() << ...
0
votes
0answers
20 views

Undefined reference to the methods of a class with header and source files [duplicate]

I am trying to investigate the mistake I made that made the linker can not link non of the methods of class Stack. Could anyone help ! main_test.cpp #include "Stack.h" #include <vector> int ...
3
votes
0answers
34 views

Why is_copy_constructible_v<vector<unique_ptr<int>>> is true, but it cannot be copied? [duplicate]

using T = std::vector<std::unique_ptr<int>>; Why std::is_copy_constructible<T> is true, but following does not compile: using T = vector<unique_ptr<int>>; T v1; T v2 = ...
0
votes
1answer
22 views

How to access 2D vector having map?

int main() { map<int,string> my_map; vector<map<int,string> > v_temp; vector< vector<map<int,string> > > vectors; for (int i = 0; i < 2; i++) ...
0
votes
1answer
35 views

Index of the lower_bound of a value in sets and maps in c++

Suppose I want to get the index of the lower_bound of a value in a set and if i type cout<<set.lower_bound(number)-set.begin()<<endl; It is showing an error: no match for ‘operator-’ ...
-1
votes
0answers
35 views

How is this function structured to deliver the solution with just 3 lines of code?

The question that drove me mad was this question from leetcode (Maximum number of balloons). I tried solving it in my own way, failed miserably. Later, I found the below code from the web, which used ...
0
votes
1answer
24 views

Double header guards in Visual Studio stl numeric implementation

In the stl implementation that comes along with Visual Studio 12.0 the numeric header looks like this #pragma once #ifndef _NUMERIC_ #define _NUMERIC_ // shortened for the sake of readibility . . . ...
0
votes
2answers
61 views

Is there a STL algorithm that finds last but that it also works on pointers?

I have existing code where I can not switch to iterators. Still I would like to use STL if possible to find the last item(or first if you consider we are iterating from end). Is that possible? std::...
0
votes
1answer
51 views

Why there is no supported iterators for some STL containers (Stack, Queue, Priority Queue)?

Across all types of iterators, why there is no supported pattern for stack, queue and priority_queue STL containers ? #include <iostream> #include <stack> #include <algorithm> int ...

15 30 50 per page
1
2 3 4 5
926