Skip to main content
9 votes
1 answer
913 views

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) { ...
Timothy Liu's user avatar
Advice
1 vote
7 replies
179 views

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 ...
Brandlingo's user avatar
  • 3,242
15 votes
4 answers
1k views

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 ...
Fedor's user avatar
  • 24.7k
8 votes
1 answer
238 views

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 ...
Dominik Kaszewski's user avatar
4 votes
2 answers
156 views

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 ...
DLWHI's user avatar
  • 145
3 votes
2 answers
125 views

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<...
Dwij Dixit's user avatar
0 votes
1 answer
189 views

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)....
Igor's user avatar
  • 6,473
1 vote
0 answers
167 views

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) ...
IzaeDA's user avatar
  • 439
4 votes
1 answer
105 views

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> #...
mistermad's user avatar
7 votes
1 answer
136 views

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/...
leaner's user avatar
  • 71
0 votes
0 answers
103 views

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 ...
Yue_Qiu's user avatar
0 votes
1 answer
104 views

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& ...
YuZ's user avatar
  • 463
3 votes
3 answers
274 views

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 (...
Atul Rawat's user avatar
-2 votes
1 answer
168 views

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 ...
John H.'s user avatar
  • 1,699
1 vote
1 answer
118 views

const auto& it = container.find( value ); Is this code safe? I'm confused because find() returns a temporary object (iterator). Could it be dangling?
sunkue's user avatar
  • 300

15 30 50 per page
1
2 3 4 5
1034