Incorrect macro definition in C ++

Is this a macro override for a class, or what exactly is it?

#define EXCEPTIONCLASS_IMPLEMENTATION(name, base, string) : public base     \
    {                                                               \
public:                                                                 \
    name() : base(string) {}                                            \
    name(const x::wrap_exc& next) : base(string,next) {};               \
    name(const x::wrap_exc& prev, const x::wrap_exc& next) :            \
        base(prev, next) {};                                            \
}
+3
source share
2 answers

This is the macro definition for the exception class.

Looks like someone wants you to write code like this:

class my_exception EXCEPTIONCLASS_IMPLEMENTATION(my_exception, std::exception, "What a mess!")

The preprocessor will spit out:

class my_exception : public std::exception { public: my_exception() : std::exception("What a mess!") {} my_exception(const x::wrap_exc& next) : std::exception("What a mess!",next) {}; my_exception(const x::wrap_exc& prev, const x::wrap_exc& next) : std::exception(prev, next) {}; }

What it is?

This is an abomination!

+9
source

this is an exception macro that throws an exception with standard constructors.

+3
source

Source: https://habr.com/ru/post/1748346/


All Articles