15,503 questions
9
votes
1
answer
913
views
Is there any way to iterate data members with STL algorithms using the C++26 reflection?
With C++26 reflection, we can simply iterate all data members of an object:
#include <iostream>
#include <meta>
struct Foo {
int x;
int y;
};
void PrintFoo(const Foo& foo) {
...
Advice
1
vote
7
replies
179
views
How does Microsofts std::lib implementation perform debug iterator checks?
In the question Why does Microsoft's implementation of std::string require 40 bytes on the stack? the observation is made, that a std::string requires 8 additional bytes in Debug mode.
After ...
15
votes
4
answers
1k
views
What is the size of std::array<T,0>?
Unlike C array, std::array is allowed to have zero length. But the current implementations differ in how std::array<T,0> is implemented, in particular the sizes of the object are different.
This ...
8
votes
1
answer
238
views
Does std::find still guarantee first element with std::execution::par?
Parallel policy states that order of iterator evaluation is not guaranteed. However, std::find*, std::search and std::mismatch all say that they return first iterator matching condition. How do those ...
4
votes
2
answers
156
views
Why std::vector::insert requires template to be CopyAssignable and CopyInsertable?
N4868 22.2.3 table 77 Sequence container requirements states that insert(iterator pos, size_type count, T value) requires T to be CopyInsertable and CopyAssignable in any sequence container. It means ...
3
votes
2
answers
125
views
Moving underlying container (std::vector or std::deque) for std::stack and std::queue [duplicate]
I had a usecase where I use a stack to process some data. Once processed, I want to output the data as a vector. But since underlying containers in stack are protected, it is now allowed to:
stack<...
0
votes
1
answer
189
views
Removing an element from a map of vectors
std::map<unsigned long, std::vector<Foo*> > fKeys = myObject->GetFoo();
for (auto it = fKeys.begin(); it != fKeys.end() && !found; ++it)
for (auto it1 = 0; it1 < (*it)....
1
vote
0
answers
167
views
python gmsh: build 3D mesh from solid-split stl surface for openFOAM
I have a simple task- I have a closed stl-surface, the whole surface is split into solids. I need to use python gmsh pack to build 3D mesh (tetra or hexa) with named-selections (lets call it this way) ...
4
votes
1
answer
105
views
How can I use a lightweight argument in unordered_set::find() method?
Must I fully build a Storage object for finding it, instead of using std::string because of having operator== for it?
#include <cstddef>
#include <functional>
#include <string>
#...
7
votes
1
answer
136
views
What is the purpose of Microsoft-specific attributes msvc::known_semantics?
When I was using Visual Studio 2022, _MSVC_KNOWN_SEMANTICS is defined as [[msvc::known_semantics]] in the header file yvals_core.h.
I try to find description in https://learn.microsoft.com/en-us/cpp/...
0
votes
0
answers
103
views
Clang&LLDB debug: summary string parsing error
I have set the compilation option -fstandalone-debug, but still cannot view the string content in vscode with clangd & CodeLLDB.
#include <iostream>
#include <string>
using namespace ...
0
votes
1
answer
104
views
C2664 Compilation Error with Nested std::for_each and Lambda Functions [duplicate]
std::vector<std::vector<bool>> grid(4, std::vector<bool>(4, true));
std::for_each(grid.begin(), grid.end(), [](auto& row) {
std::for_each(row.begin(), row.end(), [](auto& ...
3
votes
3
answers
274
views
Why does std::filesystem::absolute resolve . and .. on Windows but not on POSIX platforms?
I'm using C++17's std::filesystem::absolute to convert relative paths to absolute ones. I noticed that on Windows (MSVC), this function seems to resolve . and .. components in the path, but on Linux (...
-2
votes
1
answer
168
views
Removing elements from std::multimap [closed]
I'm using std::multimap with tens of millions of elements. The key is a pointer, and the data is a shared pointer to a class. Sometimes I need to remove a few elements, sometimes many elements, and ...
1
vote
1
answer
118
views
get iteration as reference is okay with stl functions? [duplicate]
const auto& it = container.find( value );
Is this code safe? I'm confused because find() returns a temporary object (iterator). Could it be dangling?