Static C++ check for pure virtual functions passed in constructor to...
C++ compilers warn if pure virtual functions are directly called in a constructor/destructor (but not indirectly).Binding a pure virtual function and storing the result in a class member and calling ...
View Articlestd::function discards lambda closure silently – stackoverflow.com
I have a class that does a conversion on a value using a lambda, which is captured in an std::function. This all works fine, until I try to capture a double while running on my embedded target (...
View ArticleIs there a race condition in GCC's implementation of std::call_once? –...
The main lines of GCC's implementation of std::call_once are these ones (with _GLIBCXX_HAS_GTHREADS):'libstdc++-v3/include/std/mutex:939' enum _Bits : int { _Init = 0, _Active = 1, _Done = 2 }; ...
View ArticleWhat are your favorite C++ STL alternatives? – stackoverflow.com
I don't really like the C++ stl. It is too complex.I used to code in C and often had to use the OS APIs which are a lot of work and then decided to switch to C++ because it provides OS API ...
View ArticleIs there any way to iterate data members with STL algorithms using the C++26...
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) { ...
View ArticleHow 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 ...
View ArticleWhat is the size of std::array? – stackoverflow.com
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...
View ArticleDoes 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...
View ArticleWhy std::vector::insert requires template to be CopyAssignable and...
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...
View ArticleRemoving an element from a map of vectors – stackoverflow.com
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 < ...
View ArticleHow do I open an std::fstream which internally uses char with a w_char...
This is not a duplicate of How to open an std::fstream (ofstream or ifstream) with a unicode filename? or Is there a way to create a fstream, ifstream or ofstream object with a wchar_t* or wstring ...
View Articlepython 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)...
View ArticleHow 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>#...
View ArticleWhat 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 ...
View ArticleClang&LLDB debug: summary string parsing error – stackoverflow.com
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 ...
View ArticleWhy does std::filesystem::absolute resolve . and .. on Windows but not on...
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 ...
View Articlestd::list with a custom allocator crashes when removing items –...
I wrote a memory allocator to use with standard containers. However, every time I try to remove an element from a std::list, the program crashes at the line l.remove(elt).I spent time investigating ...
View Articlec++ unordered set range-erase bug – stackoverflow.com
std::unordered_set<Vector2i> basicWalls = FindWalls(floorPositions, cardinal2D);std::unordered_set<Vector2i> cornerWalls = FindWalls(floorPositions, Diagonal2D); printf("basic ...
View Articletypedef std::basic_string ustring; – stackoverflow.com
apparently this functionality has been removed?it had been working up until i must have upgraded my compiler or something.using clang ARM 64bit on mac (Qt Creator)anyone have a drop-in replacement?
View ArticleNested std::vector brings too many memory fragmentation and pollutes the...
In my projects, there are several std::vector<std::vector<int>> dynamic arrays. The first dimension is about 10 million, the second dimension is about 10-100. Both of the dimensions are ...
View Article