Skip to content

Commit 4ecde2e

Browse files
committed
simplify abort message for bad calls
1 parent efbc135 commit 4ecde2e

2 files changed

Lines changed: 15 additions & 38 deletions

File tree

include/boost/openmethod/core.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,9 +1939,9 @@ struct init_bad_call {
19391939
type_id arg_type_id;
19401940

19411941
if constexpr (is_virtual_ptr<Arg>) {
1942-
arg_type_id = Rtti::template dynamic_type(*arg);
1942+
arg_type_id = Rtti::dynamic_type(*arg);
19431943
} else {
1944-
arg_type_id = Rtti::template dynamic_type(arg);
1944+
arg_type_id = Rtti::dynamic_type(arg);
19451945
}
19461946

19471947
error.types[Index] = arg_type_id;

include/boost/openmethod/preamble.hpp

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct odr_violation : openmethod_error {
8080
//! @tparam Registry The registry containing this policy.
8181
//! @param stream The stream to write to.
8282
template<class Registry, class Stream>
83-
auto write(Stream& stream) const -> void {
83+
auto write(Stream& stream) const {
8484
stream << "conflicting definitions of ";
8585
Registry::rtti::type_name(
8686
Registry::rtti::template static_type<Registry>(), stream);
@@ -114,7 +114,7 @@ struct not_initialized : openmethod_error {
114114
//! @tparam Registry The registry
115115
//! @tparam Stream A @ref LightweightOutputStream
116116
template<class Registry, class Stream>
117-
auto write(Stream& os) const -> void {
117+
auto write(Stream& os) const {
118118
os << "not initialized";
119119
}
120120
};
@@ -171,7 +171,7 @@ struct missing_class : openmethod_error {
171171
//! @tparam Registry The registry
172172
//! @tparam Stream A @ref LightweightOutputStream
173173
template<class Registry, class Stream>
174-
auto write(Stream& os) const -> void;
174+
auto write(Stream& os) const;
175175
};
176176

177177
//! Missing base.
@@ -212,7 +212,7 @@ struct missing_base : openmethod_error {
212212
//! @tparam Registry The registry
213213
//! @tparam Stream A @ref LightweightOutputStream
214214
template<class Registry, class Stream>
215-
auto write(Stream& os) const -> void;
215+
auto write(Stream& os) const;
216216
};
217217

218218
//! No valid overrider
@@ -225,10 +225,6 @@ struct bad_call : openmethod_error {
225225
static constexpr std::size_t max_types = 16;
226226
//! The type_ids of the arguments.
227227
type_id types[max_types];
228-
229-
protected:
230-
template<class Registry, class Stream>
231-
auto write_aux(Stream& os, const char* subtype) const -> void;
232228
};
233229

234230
//! No overrider for virtual tuple
@@ -240,8 +236,8 @@ struct no_overrider : bad_call {
240236
//! @tparam Registry The registry
241237
//! @tparam Stream A @ref LightweightOutputStream
242238
template<class Registry, class Stream>
243-
auto write(Stream& os) const -> void {
244-
write_aux<Registry>(os, "not implemented");
239+
auto write(Stream& os) const {
240+
os << "not implemented";
245241
}
246242
};
247243

@@ -254,8 +250,8 @@ struct ambiguous_call : bad_call {
254250
//! @tparam Registry The registry
255251
//! @tparam Stream A @ref LightweightOutputStream
256252
template<class Registry, class Stream>
257-
auto write(Stream& os) const -> void {
258-
write_aux<Registry>(os, "ambiguous");
253+
auto write(Stream& os) const {
254+
os << "ambiguous";
259255
}
260256
};
261257

@@ -275,7 +271,7 @@ struct final_error : openmethod_error {
275271
//! @tparam Registry The registry
276272
//! @tparam Stream A @ref LightweightOutputStream
277273
template<class Registry, class Stream>
278-
auto write(Stream& os) const -> void;
274+
auto write(Stream& os) const;
279275
};
280276

281277
namespace detail {
@@ -485,7 +481,7 @@ struct RttiFn {
485481
//! @param type The `type_id` to write.
486482
//! @param stream The stream to write to.
487483
template<typename Stream>
488-
static auto type_name(type_id type, Stream& stream) -> void;
484+
static auto type_name(type_id type, Stream& stream);
489485

490486
//! Returns a key that uniquely identifies a class.
491487
//!
@@ -1020,40 +1016,21 @@ void registry<Policies...>::require_initialized() {
10201016
}
10211017

10221018
template<class Registry, class Stream>
1023-
auto bad_call::write_aux(Stream& os, const char* subtype) const -> void {
1024-
using namespace detail;
1025-
using namespace policies;
1026-
1027-
os << "invalid call to ";
1028-
Registry::template policy<rtti>::type_name(method, os);
1029-
os << "(";
1030-
auto comma = "";
1031-
1032-
for (auto ti : range{types, types + arity}) {
1033-
os << comma;
1034-
Registry::template policy<rtti>::type_name(ti, os);
1035-
comma = ", ";
1036-
}
1037-
1038-
os << "): " << subtype;
1039-
}
1040-
1041-
template<class Registry, class Stream>
1042-
auto missing_class::write(Stream& os) const -> void {
1019+
auto missing_class::write(Stream& os) const {
10431020
os << "unknown class ";
10441021
Registry::rtti::type_name(type, os);
10451022
}
10461023

10471024
template<class Registry, class Stream>
1048-
auto missing_base::write(Stream& os) const -> void {
1025+
auto missing_base::write(Stream& os) const {
10491026
os << "missing base ";
10501027
Registry::rtti::type_name(base, os);
10511028
os << " -<| ";
10521029
Registry::rtti::type_name(derived, os);
10531030
}
10541031

10551032
template<class Registry, class Stream>
1056-
auto final_error::write(Stream& os) const -> void {
1033+
auto final_error::write(Stream& os) const {
10571034
os << "invalid call to final construct: static type = ";
10581035
Registry::rtti::type_name(static_type, os);
10591036
os << ", dynamic type = ";

0 commit comments

Comments
 (0)