'using struct in sets

I am trying to make a set of sets, what is the correct to method to do that in C++. What i am trying to achieve is something like this

One = { {"DDD", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64},{"JJ", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64},
{"kk", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64}, {"LL", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64} };

I tried like this

#include <set>
#include <iostream>
#include <algorithm>
#include <cstring>

struct Config
{
    const char* lbl;
    const char* desc;
    std::uint8_t se_2A;
    std::uint8_t se_2B;
    std::uint8_t se_2C;
    std::uint8_t se_2D;
    std::uint8_t se_2E;
    std::uint8_t su_2A;
    std::uint8_t su_2B;
    std::uint8_t su_2C;
    std::uint8_t su_2D;
    std::uint8_t su_2E;
    std::size_t total_size;
};

inline bool operator<(const Config& lhs, const Config& rhs)
{
    return lhs < rhs;
}


int main(){


    Config b1  = {"DDD", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64};
    Config b2  = {"JJ", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64};
    Config b3  = {"kk", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64};
    Config b4  = {"LL", "Numbers", 0xf, 0xf, 0xf, 0x0,0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 64};

    std::set<Config> newConfig;
    std::set<std::set<Config>> One;

    newConfig.insert(b1);
    newConfig.insert(b2);

}

But gives me this error

Program received signal SIGSEGV, Segmentation fault.
0x00005555555555b9 in operator< (
    lhs=<error reading variable: Cannot access memory at address 0x7fffff7feff8>, rhs=<error reading variable: Cannot access memory at address 0x7fffff7feff0>)
    at main.cpp:32

Whats the correct to way to do this or fix the error?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source