...
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
// #include <expected>
|
||||
#include <string_view>
|
||||
|
||||
|
||||
@@ -50,10 +50,11 @@ struct MccNullLogger {
|
||||
/* AND CLASS METHODS RETURNED VALUE */
|
||||
|
||||
template <typename T>
|
||||
concept mcc_error_c =
|
||||
std::formattable<T, char> && std::default_initializable<T> && (std::convertible_to<T, bool> || requires(const T t) {
|
||||
(bool)T() == false; // default constucted value must be a "non-error"!
|
||||
});
|
||||
concept mcc_error_c = std::default_initializable<T> && (std::convertible_to<T, bool> || requires(const T t) {
|
||||
// std::formattable<T, char> && std::default_initializable<T> && (std::convertible_to<T, bool>
|
||||
// || requires(const T t) {
|
||||
(bool)T() == false; // default constucted value must be a "non-error"!
|
||||
});
|
||||
|
||||
|
||||
template <mcc_error_c ErrT, mcc_error_c DefErrT>
|
||||
@@ -67,27 +68,27 @@ DefErrT mcc_deduced_err(ErrT const& err, DefErrT const& default_err)
|
||||
}
|
||||
|
||||
|
||||
template <typename T, typename VT>
|
||||
concept mcc_retval_c = requires(T t) {
|
||||
//
|
||||
[]<mcc_error_c ErrT>(std::expected<VT, ErrT>) {}(t);
|
||||
};
|
||||
// template <typename T, typename VT>
|
||||
// concept mcc_retval_c = requires(T t) {
|
||||
// //
|
||||
// []<mcc_error_c ErrT>(std::expected<VT, ErrT>) {}(t);
|
||||
// };
|
||||
|
||||
|
||||
// deduce an error from mcc_retval_c and default error value
|
||||
template <typename VT, mcc_retval_c<VT> RetT, mcc_error_c DefErrT>
|
||||
DefErrT mcc_deduced_err(RetT const& ret, DefErrT const& default_err)
|
||||
{
|
||||
if (ret) {
|
||||
return DefErrT{}; // no error
|
||||
}
|
||||
// // deduce an error from mcc_retval_c and default error value
|
||||
// template <typename VT, mcc_retval_c<VT> RetT, mcc_error_c DefErrT>
|
||||
// DefErrT mcc_deduced_err(RetT const& ret, DefErrT const& default_err)
|
||||
// {
|
||||
// if (ret) {
|
||||
// return DefErrT{}; // no error
|
||||
// }
|
||||
|
||||
if constexpr (std::same_as<typename RetT::error_type, DefErrT>) {
|
||||
return ret.error();
|
||||
} else {
|
||||
return default_err;
|
||||
}
|
||||
}
|
||||
// if constexpr (std::same_as<typename RetT::error_type, DefErrT>) {
|
||||
// return ret.error();
|
||||
// } else {
|
||||
// return default_err;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/* MOUNT CONSTRUCTION-RELATED STUFF */
|
||||
@@ -374,7 +375,7 @@ struct mcc_coord_pair_interface_t {
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
concept mcc_coord_pair_c = std::derived_from<T, mcc_coord_pair_interface_t> && requires(T t) {
|
||||
concept mcc_coord_pair_c = std::derived_from<T, mcc_coord_pair_interface_t> && requires(T t, const T t_const) {
|
||||
// the 'T' class must contain static constexpr member of 'pairKind' of some type
|
||||
// (usually just a enum: see mcc_coordinate.h for an example of the implementation)
|
||||
[]() {
|
||||
@@ -386,8 +387,10 @@ concept mcc_coord_pair_c = std::derived_from<T, mcc_coord_pair_interface_t> && r
|
||||
|
||||
// std::constructible_from<T, typename T::x_t const&, typename T::y_t const&>;
|
||||
|
||||
{ t.x() } -> std::same_as<typename T::x_t>;
|
||||
{ t.y() } -> std::same_as<typename T::y_t>;
|
||||
{ t_const.x() } -> std::same_as<typename T::x_t>;
|
||||
{ t_const.y() } -> std::same_as<typename T::y_t>;
|
||||
|
||||
{ t_const.epoch() } -> mcc_coord_epoch_c;
|
||||
|
||||
{ t.setX(std::declval<typename T::x_t const&>()) };
|
||||
{ t.setY(std::declval<typename T::y_t const&>()) };
|
||||
|
||||
Reference in New Issue
Block a user