Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions include/rfl/internal/cpp20/Result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <new>
#include <stdexcept>
#include <type_traits>
#include <utility>

#include "../Error.hpp"
#include "../always_inline.hpp"
Expand Down Expand Up @@ -334,7 +335,7 @@ class Result {
template <class F>
RFL_ALWAYS_INLINE auto transform(const F& _f) && {
/// Result_U is expected to be of type Result<U>.
using U = std::invoke_result_t<F, T>;
using U = decltype(std::declval<F>()(std::declval<T>()));
if (success_) {
return Result<U>(_f(std::move(*this).get_t()));
} else {
Expand Down Expand Up @@ -549,9 +550,10 @@ class Result {
* original value.
*/
template <class F>
Result<T> transform_error(F&& f) && {
static_assert(std::is_same<std::invoke_result_t<F, Error>, Error>(),
"A function passed to transform_error must return an error.");
Result<T> transform_error(F&& f) && {
static_assert(
std::is_same<decltype(std::declval<F>()(std::declval<Error>())), Error>(),
"A function passed to transform_error must return an error.");
if (!has_value()) {
return Result<T>{std::invoke(f, std::move(*this).get_err())};
} else {
Expand All @@ -577,9 +579,10 @@ class Result {
* original value.
*/
template <class F>
Result<T> transform_error(F&& f) const& {
static_assert(std::is_same<std::invoke_result_t<F, Error>, Error>(),
"A function passed to transform_error must return an error.");
Result<T> transform_error(F&& f) const& {
static_assert(
std::is_same<decltype(std::declval<F>()(std::declval<Error>())), Error>(),
"A function passed to transform_error must return an error.");
if (!has_value()) {
return Result<T>{std::invoke(f, get_err())};
} else {
Expand Down
6 changes: 4 additions & 2 deletions include/rfl/internal/nth_element_t.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef RFL_INTERNAL_NTH_ELEMENT_T_HPP_
#define RFL_INTERNAL_NTH_ELEMENT_T_HPP_

#include <utility>

#include "nth_element.hpp"

namespace rfl::internal {
Expand All @@ -19,8 +21,8 @@ struct TypeWrapper {

template <int N, class... Ts>
using nth_element_t =
typename std::invoke_result_t<decltype(nth_element<N, TypeWrapper<Ts>...>),
TypeWrapper<Ts>...>::Type;
decltype(nth_element<N, TypeWrapper<Ts>...>(
std::declval<TypeWrapper<Ts>>()...))::Type;

#endif

Expand Down
6 changes: 3 additions & 3 deletions include/rfl/internal/processed_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RFL_INTERNAL_PROCESSED_T_HPP_

#include <type_traits>
#include <utility>

#include "../Processors.hpp"
#include "ptr_named_tuple_t.hpp"
Expand All @@ -16,9 +17,8 @@ template <class StructType, class... Ps>
struct Processed<StructType, Processors<Ps...>> {
using PtrNamedTupleType = ptr_named_tuple_t<StructType>;
using type = typename remove_ptrs_nt<
std::invoke_result_t<decltype(Processors<Ps...>::template process<
StructType, PtrNamedTupleType>),
PtrNamedTupleType>>::NamedTupleType;
decltype(Processors<Ps...>::template process<StructType, PtrNamedTupleType>(
std::declval<PtrNamedTupleType>()))>::NamedTupleType;
};

template <class StructType, class ProcessorsType>
Expand Down
3 changes: 2 additions & 1 deletion include/rfl/internal/ptr_named_tuple_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define RFL_INTERNAL_PTR_FIELD_TUPLE_T_HPP_

#include <type_traits>
#include <utility>

#include "to_ptr_named_tuple.hpp"

namespace rfl::internal {

template <class T>
using ptr_named_tuple_t =
std::invoke_result_t<decltype(to_ptr_named_tuple<T>), T>;
decltype(to_ptr_named_tuple<T>(std::declval<T>()));

} // namespace rfl::internal

Expand Down
3 changes: 2 additions & 1 deletion include/rfl/internal/tag_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#define RFL_INTERNAL_TAG_T_HPP_

#include <type_traits>
#include <utility>

#include "StringLiteral.hpp"
#include "make_tag.hpp"

namespace rfl::internal {

template <internal::StringLiteral _discriminator, class T>
using tag_t = std::invoke_result_t<decltype(make_tag<_discriminator, T>), T>;
using tag_t = decltype(make_tag<_discriminator, T>(std::declval<T>()));

} // namespace rfl::internal

Expand Down
6 changes: 4 additions & 2 deletions include/rfl/internal/variant/result_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
#define RFL_INTERNAL_VARIANT_RESULT_T_HPP_

#include <type_traits>
#include <utility>

#include "../nth_element_t.hpp"

namespace rfl::internal::variant {

template <class F, class... AlternativeTypes>
using result_t = std::remove_cv_t<std::invoke_result_t<
std::remove_cvref_t<F>, internal::nth_element_t<0, AlternativeTypes...>&>>;
using result_t = std::remove_cv_t<decltype(
std::declval<std::remove_cvref_t<F>>()(
std::declval<internal::nth_element_t<0, AlternativeTypes...>&>()))>;

} // namespace rfl::internal::variant

Expand Down
11 changes: 7 additions & 4 deletions include/rfl/parsing/ParserTaggedUnion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <map>
#include <sstream>
#include <type_traits>
#include <utility>

#include "../Result.hpp"
#include "../TaggedUnion.hpp"
Expand Down Expand Up @@ -128,8 +129,9 @@ struct ParserTaggedUnion<R, W, TaggedUnion<_discriminator, AlternativeTypes...>,
return Parser<R, W, Variant<AlternativeTypes...>,
ProcessorsType>::to_schema(_definitions);
} else {
using VariantType = std::variant<std::invoke_result_t<
decltype(wrap_if_necessary<AlternativeTypes>), AlternativeTypes>...>;
using VariantType = std::variant<decltype(
wrap_if_necessary<AlternativeTypes>(std::declval<AlternativeTypes>()))
...>;
return Parser<R, W, VariantType, ProcessorsType>::to_schema(_definitions);
}
}
Expand Down Expand Up @@ -191,8 +193,9 @@ struct ParserTaggedUnion<R, W, TaggedUnion<_discriminator, AlternativeTypes...>,
return wrap_error(stream.str(), std::move(_e));
};

using T = tagged_union_wrapper_no_ptr_t<std::invoke_result_t<
decltype(wrap_if_necessary<AlternativeType>), AlternativeType>>;
using T = tagged_union_wrapper_no_ptr_t<decltype(
wrap_if_necessary<AlternativeType>(std::declval<AlternativeType>()
))>;

*_result = Parser<R, W, T, ProcessorsType>::read(_r, _var)
.transform(get_fields)
Expand Down
2 changes: 0 additions & 2 deletions include/rfl/parsing/TupleReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class TupleReader {
TupleReader(const R* _r, TupleType* _tuple)
: num_set_(0), r_(_r), tuple_(_tuple) {}

~TupleReader() = default;

/**
* @brief Handles any fields that were missing from the input.
*
Expand Down
5 changes: 3 additions & 2 deletions include/rfl/parsing/VariantAlternativeWrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RFL_PARSING_VARIANTALTERNATIVEWRAPPER_HPP_

#include <type_traits>
#include <utility>

#include "../Field.hpp"
#include "../Literal.hpp"
Expand Down Expand Up @@ -44,8 +45,8 @@ consteval auto make_tag() {
}

template <class T, bool _remove_namespaces = true>
using tag_t = std::invoke_result_t<
decltype(make_tag<std::remove_cvref_t<std::remove_pointer_t<T>>, _remove_namespaces>)>;
using tag_t = decltype(make_tag<std::remove_cvref_t<std::remove_pointer_t<T>>,
_remove_namespaces>());

} // namespace vaw

Expand Down
8 changes: 4 additions & 4 deletions include/rfl/view_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RFL_VIEW_T_HPP_

#include <type_traits>
#include <utility>

#include "Processors.hpp"
#include "internal/ptr_named_tuple_t.hpp"
Expand All @@ -10,10 +11,9 @@ namespace rfl {

/// Generates the named tuple that would be the result of to_view
template <class T, class... Ps>
using view_t =
std::invoke_result_t<decltype(Processors<Ps...>::template process<
T, internal::ptr_named_tuple_t<T>>),
internal::ptr_named_tuple_t<T>>;
using view_t = decltype(Processors<Ps...>::template process<
T, internal::ptr_named_tuple_t<T>>(
std::declval<internal::ptr_named_tuple_t<T>>()));

} // namespace rfl

Expand Down
2 changes: 1 addition & 1 deletion vcpkg
Submodule vcpkg updated 1725 files
Loading