Comment by HolyBlackCat on failing to wrap a string literal as a class...
What's up with const std::string tmp{str};?
View ArticleAnswer by HolyBlackCat for Deduce template parameters for std::variant...
To get a parent std::variant from a class derived from it (if I understand you correctly, you want to accept derived classes too), do this:template <typename ...P>std::variant<P...>...
View ArticleAnswer by HolyBlackCat for Is there a "happens before" relationship if we...
Whether or not you have a data race UB depends on whether i.load(std::memory_order::acquire); (informally) happens after i.store(1, std::memory_order::release);.Or, technically speaking, if .load()...
View ArticleComment by HolyBlackCat on MinGW - compilation errors when build grpc
Obligatory reminder that MSYS2 is a thing, it both provides a prebuilt grpc, and a newer version of mingw.
View ArticleComment by HolyBlackCat on Makefile: Include gives "No such file or...
It doesn't say that the Makefile2 is not found, it says that include is not found. Everything indented with a tab is a shell command (except for $(...) substitutions in it), while include is not a...
View ArticleComment by HolyBlackCat on c++ hello world program not printing anything
This is yet another DLL problem. Either add -static to the compiler flags (or rather linker flags), or move C:\msys64\ucrt64\bin (or whatever subdirectory you added to the PATH) to be the first...
View ArticleComment by HolyBlackCat on When a lambda capture is created exactly?
x is copied (if captured by value) into the lambda when the lambda is created.
View ArticleComment by HolyBlackCat on Why does each Block in the MSVC implementation of...
Either don't use this container, or don't use MSVC STL (MinGW for the win).
View ArticleWhy does `std::integral_constant` have a `::type` that refers to itself?
I'm reading the documentation on std::integral_constant, and apparently it includes using type that refers to itself.template <typename T, T Value>struct integral_constant{ using type =...
View ArticleComment by HolyBlackCat on hello world program not printing anything
This is yet another DLL problem. Either add -static to the compiler flags (or rather linker flags), or move C:\msys64\ucrt64\bin (or whatever subdirectory you added to the PATH) to be the first...
View ArticleComment by HolyBlackCat on In C++, can I use std::set as a heap data structure?
Use std::vector and std::push_heap and friends.
View ArticleComment by HolyBlackCat on How to debug DLL issues in MinGW?
I'm tired of answering the same question a few times a week, so here's a canonical duplicate.
View ArticleComment by HolyBlackCat on How do I compile code that uses both Physac and...
You should report a bug to both of those libraries for not prefixing their stuff with the library name. Until they fix it, isolate one of the libraries into its own translation unit (include it in a...
View ArticleComment by HolyBlackCat on What are the benefits and drawbacks of some ways...
Isn't the friend version alone enough?
View ArticleWhat are MSYS2 environments? How do I pick one?
MSYS2 is said to have different environments.What are they? How do I choose which one to use? What's the difference between MINGW64 and UCRT64?(This Q&A is intended as a canonical duplicate on this...
View ArticleAnswer by HolyBlackCat for What are MSYS2 environments? How do I pick one?
See the official manual. Following environments are available: UCRT64, MINGW64, CLANG64, MSYS, and others (see link).UCRT64 is a good default, MINGW64 is popular too, but the alternatives are explained...
View ArticleHow do I use SDL2 in my programs correctly?
I want to make a game using SDL2, but I'm unable to compile and/or run my code, please help!SDL2 is notoriously hard to set up, and it's often the first library aspiring game developers try to use.This...
View ArticleAnswer by HolyBlackCat for How do I use SDL2 in my programs correctly?
This answer is about MinGW / GCC, and not Visual Studio.This answer only applies to Windows.Common errorsThe common errors are:SDL.h: No such file or directory (when compiling)Various SDL_main...
View ArticleAnswer by HolyBlackCat for How to debug DLL issues in MinGW?
What do the errors mean?Your program requires several .dll ("shared libraries") to run. Those are either parts of the standard library (distributed with your compiler), or third-party libraries you're...
View ArticleComment by HolyBlackCat on How does the virtual keyword break compilation?
@lucidbrot Here's the part about the move constructor, for example: eel.is/c++draft/class#copy.ctor-8.4 Also: howardhinnant.github.io/smf.jpg
View Article