Change all decay to remove_cvref.

This commit is contained in:
hazby2002
2023-12-29 17:05:16 +08:00
parent 38783b8907
commit 2d45ddfdc8
62 changed files with 409 additions and 394 deletions
+7 -5
View File
@@ -13,7 +13,7 @@ namespace rfl {
namespace parsing {
template <class R, class W, class MapType>
requires AreReaderAndWriter<R, W, MapType>
requires AreReaderAndWriter<R, W, MapType>
struct MapParser {
public:
using InputObjectType = typename R::InputObjectType;
@@ -22,8 +22,9 @@ struct MapParser {
using OutputObjectType = typename W::OutputObjectType;
using OutputVarType = typename W::OutputVarType;
using KeyType = std::decay_t<typename MapType::value_type::first_type>;
using ValueType = std::decay_t<typename MapType::value_type::second_type>;
using KeyType = std::remove_cvref_t<typename MapType::value_type::first_type>;
using ValueType =
std::remove_cvref_t<typename MapType::value_type::second_type>;
static Result<MapType> read(const R& _r, const InputVarType& _var) noexcept {
const auto to_map = [&](const auto& _obj) { return make_map(_r, _obj); };
@@ -33,7 +34,8 @@ struct MapParser {
static OutputVarType write(const W& _w, const MapType& _m) noexcept {
auto obj = _w.new_object();
for (const auto& [k, v] : _m) {
auto parsed_val = Parser<R, W, std::decay_t<ValueType>>::write(_w, v);
auto parsed_val =
Parser<R, W, std::remove_cvref_t<ValueType>>::write(_w, v);
if constexpr (internal::has_reflection_type_v<KeyType>) {
using ReflT = typename KeyType::ReflectionType;
@@ -100,7 +102,7 @@ struct MapParser {
auto pair = std::make_pair(std::move(_pair.first), std::move(_val));
return make_key(pair);
};
return Parser<R, W, std::decay_t<ValueType>>::read(_r, _pair.second)
return Parser<R, W, std::remove_cvref_t<ValueType>>::read(_r, _pair.second)
.and_then(to_pair)
.value();
}