Let\'s say I have this Haskell code:
data RigidBody = RigidBody Vector3 Vector3 Float Shape -- position, velocity, mass an
To throw another possibility in here, you can also use boost::variant
which is being added to the standard library in C++17 as std::variant
:
struct Ball { float radius; };
struct ConvexPolygon { Triangle t; }
using Shape = boost::variant;
The advantages of this approach:
Some disadvantages: