@no_name1991
Ich bin mal lieb. Ich habe deinen Code mal zum laufen gebracht:
#include <variant>
#include <string>
#include <map>
#include <iostream>
class sbasic
{
public:
unsigned short int length = 0; // laenge
unsigned short int width = 0; // breite
unsigned short int height = 0; // hoehe
unsigned short int type = 0; // art
unsigned long long int x = 0; // Position
unsigned long long int y = 0; // Position
unsigned long long int z = 0; // Position
public:
sbasic(unsigned short int l, unsigned short int w, unsigned short int h, unsigned short int t, unsigned long long int mx, unsigned long long int my, unsigned long long int mz) :
length(l),
width(w),
height(h),
type(t),
x(mx),
y(my),
z(mz)
{
}
bool operator<(const sbasic& rhs) const
{
return length < rhs.length; // Musst du noch definieren. Eine map ist immer sortiert und hier nutzt diese immer den < Operator.
}
};
//zuladung
class spayload
{
public:
unsigned short int type; // art
public:
spayload(unsigned short int t) :
type(t)
{
}
};
//zuladung menge
struct spayloadamount {
unsigned short int type[64]; // art
unsigned short int amount[64]; // menge an zuladung
};
using MySpecVariant = std::variant<spayload, spayloadamount>;
int main(int argc, char* argv[]) {
std::map<sbasic, MySpecVariant> mm;
//mm.insert(std::pair<unsigned short int, unsigned short int, unsigned short int, unsigned short int, unsigned long long int, unsigned long long int, unsigned long long int>(100, 100, 100, 100, 100, 100, 100))
mm.insert({ sbasic(101, 102, 103, 104, 1, 2, 3), spayload(5) });
return 0;
}