Skip to content

Commit 3a1f7b8

Browse files
committed
Use a single concept in std::conditional_t
1 parent 5f67ba5 commit 3a1f7b8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/graphqlservice/GraphQLService.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,10 @@ concept ObjectBaseType = std::is_base_of_v<Object, Type>;
884884
template <typename Type>
885885
concept ObjectDerivedType = ObjectBaseType<Type> && !ObjectType<Type>;
886886

887+
// Test if a nullable type is std::shared_ptr<Type> or std::optional<T>.
888+
template <typename Type, TypeModifier... Other>
889+
concept NullableSharedPtr = OnlyNoneModifiers<Other...> && ObjectBaseType<Type>;
890+
887891
// Test if this method should std::static_pointer_cast an ObjectDerivedType to
888892
// std::shared_ptr<const Object>.
889893
template <typename Type, TypeModifier Modifier, TypeModifier... Other>
@@ -914,8 +918,8 @@ struct ModifiedResult
914918
struct ResultTraits
915919
{
916920
using type = typename std::conditional_t<NullableModifier<Modifier>,
917-
typename std::conditional_t<OnlyNoneModifiers<Other...> && ObjectBaseType<U>,
918-
std::shared_ptr<U>, std::optional<typename ResultTraits<U, Other...>::type>>,
921+
typename std::conditional_t<NullableSharedPtr<U, Other...>, std::shared_ptr<U>,
922+
std::optional<typename ResultTraits<U, Other...>::type>>,
919923
typename std::conditional_t<ListModifier<Modifier>,
920924
std::vector<typename ResultTraits<U, Other...>::type>,
921925
typename std::conditional_t<ObjectBaseType<U>, std::shared_ptr<U>, U>>>;

0 commit comments

Comments
 (0)