openMSX
MSXException.hh
Go to the documentation of this file.
1#ifndef MSXEXCEPTION_HH
2#define MSXEXCEPTION_HH
3
4#include "strCat.hh"
5
6#include <concepts>
7#include <string>
8
9namespace openmsx {
10
12{
13public:
14 explicit MSXException() = default;
15
16 explicit MSXException(std::string message_)
17 : message(std::move(message_)) {}
18
19 template<typename T, typename... Args>
20 requires(!std::same_as<MSXException, std::remove_cvref_t<T>>) // don't block copy-constructor
21 explicit MSXException(T&& t, Args&&... args)
22 : message(strCat(std::forward<T>(t), std::forward<Args>(args)...))
23 {
24 }
25
26 [[nodiscard]] const std::string& getMessage() const & { return message; }
27 [[nodiscard]] std::string getMessage() && { return std::move(message); }
28
29private:
30 std::string message;
31};
32
34{
35public:
36 explicit FatalError(std::string message_)
37 : message(std::move(message_)) {}
38
39 template<typename T, typename... Args>
40 requires(!std::same_as<FatalError, std::remove_cvref_t<T>>) // don't block copy-constructor
41 explicit FatalError(T&& t, Args&&... args)
42 : message(strCat(std::forward<T>(t), std::forward<Args>(args)...))
43 {
44 }
45
46 [[nodiscard]] const std::string& getMessage() const & { return message; }
47 [[nodiscard]] std::string getMessage() && { return std::move(message); }
48
49private:
50 std::string message;
51};
52
53} // namespace openmsx
54
55#endif
TclObject t
FatalError(T &&t, Args &&... args)
std::string getMessage() &&
const std::string & getMessage() const &
FatalError(std::string message_)
MSXException(std::string message_)
std::string getMessage() &&
const std::string & getMessage() const &
MSXException(T &&t, Args &&... args)
This file implemented 3 utility functions:
Definition Autofire.cc:11
STL namespace.
std::string strCat()
Definition strCat.hh:703