std Questions
2
Solved
I'm learning to program my Arduino, but I have a pretty solid background in C++, which means that I was very disappointed to find that I couldn't use the C++ Standard Library. I've been looking aro...
3
Solved
I am new to std::thread. I need to put a std::thread to sleep from another thread, is that possible? In examples, all I see is code like:
std::this_thread::sleep_for(std::chrono::seconds(1));
But ...
Emergent asked 12/10, 2012 at 12:55
4
I compiled & installed gcc4.4 using macports.
When I try to compile using -> g++ -g -Wall -ansi -pthread -std=c++0x main.cpp...:
#include <thread>
...
std::thread t(handle);
t.join(...
Budgerigar asked 25/3, 2010 at 21:39
4
Solved
2
Solved
I'm implementing an iterator that iterates over the results of a generator function rather than over a data structure in memory such as a vector or map.
Reading through the final working draft for...
Smug asked 8/10, 2017 at 1:52
1
Solved
Title.
I am implementing this class:
#include <span>
#include <vector>
class MyClass {
public:
std::span<int *> numbers(void) {
return m_numbers;
}
std::span<const int *&...
2
Solved
I am trying to update some older code to the coming C++20 language using current GCC10.
I was not able to update some templates because they used a std::enable_if<std::is_enum_v<T>> co...
Heshum asked 18/5, 2020 at 17:8
5
Solved
I have some strings read from the database, stored in a char* and in UTF-8 format (you know, "á" is encoded as 0xC3 0xA1). But, in order to write them to a file, I first need to convert them to ANS...
1
Solved
I don't understand why in foobar below I need to specify std::vector<int>{} whereas in foobar2 I do not:
#include <iostream>
#include <memory>
#include <vector>
#include <...
Hydrotropism asked 30/9, 2023 at 0:56
20
Solved
All I want to do is to check whether an element exists in the vector or not, so I can deal with each case.
if ( item_present )
do_this();
else
do_that();
5
Solved
Why should I prefer one or another in practice?
What are the technical differences except that std::thread is a class?
Unwearied asked 30/10, 2012 at 7:3
5
Solved
C++ primer, 5th, 14.8.2, Using a Library Function Object with the Algorithms:
vector<string *> nameTable; // vector of pointers
// error: the pointers in nameTable are unrelated, so < is u...
Forearm asked 13/3, 2017 at 11:33
1
Solved
I think it is confusing that there is no parallel version of std::accumulate in the C++ standard. It appears to me that it would be trivial to implement it in parallel, for instance, based on OpenM...
Selfpronouncing asked 6/9, 2023 at 0:19
2
Solved
std::byte is an abstraction that is supposed to provide a type safe(r) access to regions of memory in C++, starting with the new standard 17. However, it's declared this way according to http://en....
Churr asked 12/6, 2017 at 20:27
2
Solved
1
Solved
Background:
I'm trying to port a library to compile on MSVC.
That library stores data in a tuple of vectors (std::tuple<std::vector<Ts>...>), and uses a custom iterator to iterate over ...
Maples asked 17/8, 2023 at 13:24
1
I'm encountering an issue while compiling the following C++ code that utilizes the <chrono> library:
#include "log.hpp"
#include <chrono>
#include <iomanip>
#include <...
1
Solved
I tried these codes, to compare std::copy and std::string's constructor.
#include <chrono>
#include <iostream>
#include <vector>
void construct_test() {
std::vector<uint8_t&g...
Neonatal asked 8/8, 2023 at 9:29
13
Solved
What does the phrase std::string::npos mean in the following snippet of code?
found = str.find(str2);
if (found != std::string::npos)
std::cout << "first 'needle' found at: " << int(...
5
I'm trying to use a std::string as a key in a std::map however, i'm unable to find() correctly. My code is somewhat complicated and large so this is a small program that demonstrates the problem I'...
5
Solved
How can I use a std::valarray to store/manipulate a 2D array?
I'd like to see an example of a 2D array with elements accessed by row/column indices. Something like this pseudo code:
matrix(i,j) =...
Faroff asked 2/2, 2010 at 20:57
6
In std::sort you can supply a third argument which is the basis for how it sorts a list. If you want the first argument to come first, then you return true. If you want the second argument to come ...
3
Solved
I need a filesystem library for use with a C++11-capable compiler or a C++14-capable one - so it can't be be from C++17.
Now, I know that the filesystem library going into C++17 is based based on...
Illyes asked 30/11, 2016 at 22:17
5
Solved
This may just be a simple mistake that I'm not seeing, but
I think I'm simply doing something wrong. Don't worry I'm not using namespace std in my header
functions or anything which seemed to be ...
Branton asked 7/8, 2012 at 20:44
9
Solved
C is somewhat, not exactly, a subset of C++. So we can use most of the C functions/headers in C++ by changing the name a little bit (stdio.h to cstdio, stdlib.h to cstdlib).
My question is actual...
Holograph asked 16/9, 2015 at 10:26
© 2022 - 2025 — McMap. All rights reserved.