So I need to represent, in C++, a structure like "a Value can be a bool, a string, a list of Values, or a map from string to Value"

This should be easy, something like:
class Value;
using String = std::string;
using List = std::vector;
using Map = std::unordered_map;

class Value {
// something tagged-union-like
};

However unordered_map can't have incomplete types as a parameter, even though it's totally possible T_T unordered_map is just pointers #cpp #programming

Side note: I would LOVE to be able to use C++'s native tagged unions: std::variant. But defining something recursive with std::variant is impossible because you can't forward declare an alias. I want to do:

declare_alias Value;
using String = std::string;
using List = std::vector;
using Value = std::variant;

But there is no way to do that. You can only forward declare classes, structs and functions. So I'm stuck wrapping the variant in a class. #cplusplus#cpp

I'm stuck trying to decide whether to implement my own hash table, or use an additional and unnecessary level of pointers with unordered_map

C++17 gave us std::vector, std::list and std::forward_list of incomplete types (HOW DID IT TAKE THAT LONG), but from what I can tell, not even C++26 will have std::unordered_map of incomplete types :(

Of course in #Rust, vectors and hash maps and everything else just works with recursive types no problem

#cplusplus#cpp

alcinnz
alcinnz boosted

I added hot reloading of C++ gameplay code to my game :D

This is possible because "engine" code and "gameplay" code is split into different shared libraries. So when you hit F5, it compiles a new shared library for the gameplay code and loads the new one (as well as reloading all the assets etc).

#cplusplus#gamedev #programming

Screen recording where I demonstrate changing gameplay source code and assets and hot reloading the game
Screen recording where I demonstrate changing gameplay source code and assets and hot reloading the game
alcinnz
alcinnz boosted

I was able to use precompiled headers to significantly speed up recompilation! A full rebuild of all the gameplay code used to take 4.5 seconds, on my laptop. Now that I made it pre-compile the engine headers, it does it in 1.6 seconds.

I've tried precompiled headers before and struggled to get real speed-up, but I guess this is literally the perfect case for it; every gameplay source code is gonna include the exact same engine library header 😊 #cplusplus#cpp

I was able to use precompiled headers to significantly speed up recompilation! A full rebuild of all the gameplay code used to take 4.5 seconds, on my laptop. Now that I made it pre-compile the engine headers, it does it in 1.6 seconds.

I've tried precompiled headers before and struggled to get real speed-up, but I guess this is literally the perfect case for it; every gameplay source code is gonna include the exact same engine library header 😊 #cplusplus#cpp

I added hot reloading of C++ gameplay code to my game :D

This is possible because "engine" code and "gameplay" code is split into different shared libraries. So when you hit F5, it compiles a new shared library for the gameplay code and loads the new one (as well as reloading all the assets etc).

#cplusplus#gamedev #programming

Screen recording where I demonstrate changing gameplay source code and assets and hot reloading the game
Screen recording where I demonstrate changing gameplay source code and assets and hot reloading the game