jeremy-rifkin / libassert

The most over-engineered C++ assertion library
MIT License
539 stars 36 forks source link

Fix compilation with C++20 #65

Closed Sirraide closed 1 year ago

Sirraide commented 1 year ago

Due to changes to aggregate initialisation in C++20 [dcl.init.aggr], a class type that has a user-declared constructor is no longer considered an aggregate, which means that code such as

struct S {
    int x;
    S(const S&) = delete;
};

S s{1}; // Error in C++20: Not an aggregate.

fails to compile in C++20, even though it was well-formed in C++17.

There was one instance of this in the library, i.e. opaque_trace, which is aggregate-initialised in the library, but is no longer an aggregate as of C++20. This pr adds a constructor to the class to make it possible again to initialise an instance of it with a void*.

jeremy-rifkin commented 1 year ago

Not sure why the sonar run failed, I'll deal with that later