mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 00:26:19 +08:00
Change all decay to remove_cvref.
This commit is contained in:
@@ -41,12 +41,12 @@ class OutputValue : public OutputVar {
|
||||
private:
|
||||
/// Transforms the underlying value into a string.
|
||||
std::string to_string() {
|
||||
if constexpr (std::is_same<std::decay_t<T>, std::string>()) {
|
||||
if constexpr (std::is_same<std::remove_cvref_t<T>, std::string>()) {
|
||||
return val_;
|
||||
} else if constexpr (std::is_same<std::decay_t<T>, bool>()) {
|
||||
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
|
||||
return val_ ? "true" : "false";
|
||||
} else if constexpr (std::is_floating_point<std::decay_t<T>>() ||
|
||||
std::is_integral<std::decay_t<T>>()) {
|
||||
} else if constexpr (std::is_floating_point<std::remove_cvref_t<T>>() ||
|
||||
std::is_integral<std::remove_cvref_t<T>>()) {
|
||||
return std::to_string(val_);
|
||||
} else {
|
||||
static_assert(always_false_v<T>, "Unsupported type");
|
||||
|
||||
@@ -53,7 +53,7 @@ struct Reader {
|
||||
const std::variant<pugi::xml_node, pugi::xml_attribute>&
|
||||
_node_or_attribute) {
|
||||
const auto cast = [](const auto& _n) -> Result<pugi::xml_node> {
|
||||
using Type = std::decay_t<decltype(_n)>;
|
||||
using Type = std::remove_cvref_t<decltype(_n)>;
|
||||
if constexpr (std::is_same<Type, pugi::xml_node>()) {
|
||||
return _n;
|
||||
} else {
|
||||
@@ -82,7 +82,7 @@ struct Reader {
|
||||
template <class T>
|
||||
rfl::Result<T> to_basic_type(const InputVarType _var) const noexcept {
|
||||
const auto get_value = [](const auto& _n) -> std::string {
|
||||
using Type = std::decay_t<decltype(_n)>;
|
||||
using Type = std::remove_cvref_t<decltype(_n)>;
|
||||
if constexpr (std::is_same<Type, pugi::xml_node>()) {
|
||||
return std::string(_n.child_value());
|
||||
} else {
|
||||
@@ -90,11 +90,11 @@ struct Reader {
|
||||
}
|
||||
};
|
||||
|
||||
if constexpr (std::is_same<std::decay_t<T>, std::string>()) {
|
||||
if constexpr (std::is_same<std::remove_cvref_t<T>, std::string>()) {
|
||||
return std::visit(get_value, _var.node_or_attribute_);
|
||||
} else if constexpr (std::is_same<std::decay_t<T>, bool>()) {
|
||||
} else if constexpr (std::is_same<std::remove_cvref_t<T>, bool>()) {
|
||||
return std::visit(get_value, _var.node_or_attribute_) == "true";
|
||||
} else if constexpr (std::is_floating_point<std::decay_t<T>>()) {
|
||||
} else if constexpr (std::is_floating_point<std::remove_cvref_t<T>>()) {
|
||||
const auto str = std::visit(get_value, _var.node_or_attribute_);
|
||||
try {
|
||||
return static_cast<T>(std::stod(str));
|
||||
@@ -102,7 +102,7 @@ struct Reader {
|
||||
return Error("Could not cast '" + std::string(str) +
|
||||
"' to floating point value.");
|
||||
}
|
||||
} else if constexpr (std::is_integral<std::decay_t<T>>()) {
|
||||
} else if constexpr (std::is_integral<std::remove_cvref_t<T>>()) {
|
||||
const auto str = std::visit(get_value, _var.node_or_attribute_);
|
||||
try {
|
||||
return static_cast<T>(std::stoi(str));
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace xml {
|
||||
// lax rules when things are required.
|
||||
template <class T>
|
||||
consteval bool is_required_for_xml() {
|
||||
using Type = std::decay_t<std::remove_pointer_t<T>>;
|
||||
using Type = std::remove_cvref_t<std::remove_pointer_t<T>>;
|
||||
if constexpr (internal::has_reflection_type_v<T>) {
|
||||
return is_required_for_xml<typename T::ReflectionType>();
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,7 @@ consteval auto get_root_name() {
|
||||
return _root;
|
||||
} else {
|
||||
return internal::remove_namespaces<
|
||||
internal::get_type_name<std::decay_t<T>>()>();
|
||||
internal::get_type_name<std::remove_cvref_t<T>>()>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user