di 0.1.0
Loading...
Searching...
No Matches
begin.h
Go to the documentation of this file.
1#pragma once
2
7#include "di/meta/core.h"
8#include "di/meta/language.h"
9#include "di/meta/util.h"
11#include "di/util/forward.h"
12
13namespace di::container {
14struct BeginFunction;
15
16namespace detail {
17 template<typename T>
18 concept ArrayBegin = concepts::LanguageArray<meta::RemoveReference<T>>;
19
20 template<typename T>
21 concept CustomBegin = concepts::TagInvocable<BeginFunction, T> &&
22 concepts::Iterator<meta::Decay<meta::TagInvokeResult<BeginFunction, T>>>;
23
24 template<typename T>
25 concept MemberBegin = requires(T&& container) {
26 { util::forward<T>(container).begin() } -> concepts::Iterator;
27 };
28}
29
31 template<typename T>
33 (detail::ArrayBegin<T> || detail::CustomBegin<T> || detail::MemberBegin<T>) )
34 constexpr auto operator()(T&& container) const {
35 if constexpr (detail::ArrayBegin<T>) {
36 return container + 0;
37 } else if constexpr (detail::CustomBegin<T>) {
38 return function::tag_invoke(*this, util::forward<T>(container));
39 } else {
40#ifdef DI_CLANG
41#pragma clang diagnostic push
42#pragma clang diagnostic ignored "-Wunused-result"
43#endif
44 return util::forward<T>(container).begin();
45#ifdef DI_CLANG
46#pragma clang diagnostic pop
47#endif
48 }
49 }
50};
51
52constexpr inline auto begin = BeginFunction {};
53}
54
55namespace di {
57}
Definition sequence.h:12
constexpr struct di::container::EnableBorrowedContainer enable_borrowed_container
constexpr auto begin
Definition begin.h:52
constexpr tag_invoke_detail::TagInvokeFn tag_invoke
Definition tag_invoke.h:22
RemoveConst< RemoveVolatile< T > > RemoveCV
Definition core.h:57
constexpr auto in_place_type
Definition in_place_type.h:12
Definition any_storable.h:9
Definition begin.h:30
constexpr auto operator()(T &&container) const
Definition begin.h:34