di 0.1.0
Loading...
Searching...
No Matches
end.h
Go to the documentation of this file.
1#pragma once
2
8#include "di/meta/core.h"
9#include "di/meta/language.h"
10#include "di/meta/util.h"
12#include "di/types/size_t.h"
13#include "di/util/forward.h"
14
15namespace di::container {
16struct EndFunction;
17
18namespace detail {
19 template<typename T>
20 concept ArrayEnd = concepts::BoundedLanguageArray<meta::RemoveReference<T>>;
21
22 template<typename T>
23 concept CustomEnd =
24 concepts::TagInvocable<EndFunction, T> &&
25 concepts::SentinelFor<meta::Decay<meta::TagInvokeResult<EndFunction, T>>, meta::ContainerIterator<T>>;
26
27 template<typename T>
28 concept MemberEnd = requires(T&& container) {
29 { util::forward<T>(container).end() } -> concepts::SentinelFor<meta::ContainerIterator<T>>;
30 };
31}
32
34 template<typename T>
36 (detail::ArrayEnd<T> || detail::CustomEnd<T> || detail::MemberEnd<T>) )
37 constexpr auto operator()(T&& container) const {
38 if constexpr (detail::ArrayEnd<T>) {
40 } else if constexpr (detail::CustomEnd<T>) {
41 return function::tag_invoke(*this, util::forward<T>(container));
42 } else {
43#ifdef DI_CLANG
44#pragma clang diagnostic push
45#pragma clang diagnostic ignored "-Wunused-result"
46#endif
47 return util::forward<T>(container).end();
48#ifdef DI_CLANG
49#pragma clang diagnostic pop
50#endif
51 }
52 }
53};
54
55constexpr inline auto end = EndFunction {};
56}
57
58namespace di {
59using container::end;
60}
Definition sequence.h:12
constexpr struct di::container::EnableBorrowedContainer enable_borrowed_container
constexpr auto end
Definition end.h:55
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
constexpr auto Extent
Definition language.h:149
RemoveConst< RemoveVolatile< T > > RemoveCV
Definition core.h:57
decltype(container::begin(util::declval< T & >())) ContainerIterator
Definition container_iterator.h:8
constexpr auto in_place_type
Definition in_place_type.h:12
Definition any_storable.h:9
Definition end.h:33
constexpr auto operator()(T &&container) const
Definition end.h:37