Skip to content

Commit fb84e09

Browse files
committed
Simplify source from tag
1 parent 18e895f commit fb84e09

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

include/kangaru/detail/source_from_tag.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,19 @@ namespace kangaru {
4444
static constexpr auto is_wrapped(auto&&) -> std::false_type;
4545

4646
template<typename T>
47-
static auto is_wrapped(SourceFor<T>) -> std::true_type;
47+
static auto is_wrapped(SourceFor<T>&&) -> std::true_type;
48+
49+
template<typename T>
50+
static constexpr auto is_wrapped_v = decltype(is_wrapped(std::declval<T>()))::value;
4851

4952
public:
50-
template<injectable T, forwarded<with_cache_using> Self> requires (not decltype(is_wrapped(std::declval<T>()))::value and wrapping_source_of<Self, SourceFor<std::remove_reference_t<T>>*> and is_cachable_v<T> and std::is_lvalue_reference_v<T>)
53+
template<injectable T, forwarded<with_cache_using> Self>
54+
requires (
55+
std::is_lvalue_reference_v<T>
56+
and is_cachable_v<T>
57+
and not is_wrapped_v<T>
58+
and wrapping_source_of<Self, SourceFor<std::remove_reference_t<T>>*>
59+
)
5160
friend constexpr auto provide(Self&& source) -> T {
5261
decltype(auto) source_for_t = kangaru::provide<SourceFor<std::remove_reference_t<T>>*>(KANGARU5_FWD(source).source);
5362
return kangaru::provide<T>(*KANGARU5_FWD(source_for_t));

0 commit comments

Comments
 (0)