Opts: Solve OptionsParser::Exception diamond inheritance problem

This commit is contained in:
2026-04-02 01:28:37 -04:00
parent 3f2d7c24ee
commit 06996d166e
2 changed files with 19 additions and 21 deletions
+7 -9
View File
@@ -29,9 +29,13 @@ public:
class Exception : public std::exception
{
public:
Exception() = default;
explicit Exception(std::string message_);
~Exception() override = default;
const char* what() const noexcept override = 0;
const char* what() const noexcept override;
protected:
std::string message;
};
std::string argv0;
@@ -45,13 +49,11 @@ public:
};
class OptionsParserError
: public std::invalid_argument, public OptionParser::Exception
: public OptionParser::Exception
{
public:
OptionsParserError(
const std::string& errorMessage, const OptionParser& parser);
const char* what() const noexcept override;
};
class JustPrintUsageNoError
@@ -59,10 +61,6 @@ class JustPrintUsageNoError
{
public:
explicit JustPrintUsageNoError(const OptionParser& parser);
const char* what() const noexcept override;
private:
std::string message;
};
#endif // OPTS_H