File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/XS/librangeV3.x/i/range/v3/utility/tagged_pair.hpp
Criterion Covered Total %
statement 2 2 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 2 2 100.0


line stmt bran cond sub pod time code
1             /// \file
2             // Range v3 library
3             //
4             // Copyright Eric Niebler 2013-present
5             // Copyright Casey Carter 2016
6             //
7             // Use, modification and distribution is subject to the
8             // Boost Software License, Version 1.0. (See accompanying
9             // file LICENSE_1_0.txt or copy at
10             // http://www.boost.org/LICENSE_1_0.txt)
11             //
12             // Project home: https://github.com/ericniebler/range-v3
13              
14             #ifndef RANGES_V3_UTILITY_TAGGED_PAIR_HPP
15             #define RANGES_V3_UTILITY_TAGGED_PAIR_HPP
16              
17             #include
18             #include
19             #include
20             #include
21             #include
22             #include
23              
24             namespace ranges
25             {
26             inline namespace v3
27             {
28             /// \cond
29             namespace detail
30             {
31             template
32             using tag_spec = meta::front>;
33              
34             template
35             using tag_elem = meta::back>;
36             }
37              
38             namespace _tagged_
39             {
40             template
41             struct chain
42             {
43             using type = Base;
44             };
45             template
46             struct chain
47             {
48             using type = typename First::template getter<
49             Base, I, meta::_t>>;
50             };
51              
52             #if RANGES_BROKEN_CPO_LOOKUP
53 1595           template struct adl_hook {};
54             #endif
55             }
56             /// \endcond
57              
58             template
59             class RANGES_EMPTY_BASES tagged
60             : public meta::_t<_tagged_::chain>
61             #if RANGES_BROKEN_CPO_LOOKUP
62             , private _tagged_::adl_hook>
63             #endif
64             {
65             CONCEPT_ASSERT(Same>());
66             using base_t = meta::_t<_tagged_::chain>;
67              
68             template
69             using can_convert =
70             meta::bool_::value &&
71             detail::is_convertible::value>;
72             public:
73             tagged() = default;
74 3190           using base_t::base_t;
75             CONCEPT_REQUIRES(MoveConstructible())
76             constexpr tagged(Base && that)
77             noexcept(std::is_nothrow_move_constructible::value)
78             : base_t(detail::move(that))
79             {}
80             CONCEPT_REQUIRES(CopyConstructible())
81             constexpr tagged(Base const &that)
82             noexcept(std::is_nothrow_copy_constructible::value)
83             : base_t(that)
84             {}
85             template>>
86             constexpr tagged(tagged && that)
87             noexcept(std::is_nothrow_constructible::value)
88             : base_t(static_cast(that))
89             {}
90             template>>
91             constexpr tagged(tagged const &that)
92             noexcept(std::is_nothrow_constructible::value)
93             : base_t(static_cast(that))
94             {}
95             template>>
96             RANGES_CXX14_CONSTEXPR tagged &operator=(tagged && that)
97             noexcept(noexcept(std::declval() = static_cast(that)))
98             {
99             static_cast(*this) = static_cast(that);
100             return *this;
101             }
102             template>>
103             RANGES_CXX14_CONSTEXPR tagged &operator=(tagged const &that)
104             noexcept(noexcept(std::declval() = static_cast(that)))
105             {
106             static_cast(*this) = static_cast(that);
107             return *this;
108             }
109             template
110             typename = meta::if_c>::value>,
111             typename = decltype(std::declval() = std::declval())>
112             RANGES_CXX14_CONSTEXPR tagged &operator=(U && u)
113             noexcept(noexcept(std::declval() = static_cast(u)))
114             {
115             static_cast(*this) = static_cast(u);
116             return *this;
117             }
118             template
119             RANGES_CXX14_CONSTEXPR meta::if_c::value>
120             swap(tagged &that)
121             noexcept(is_nothrow_swappable::value)
122             {
123             ranges::swap(static_cast(*this), static_cast(that));
124             }
125             #if !RANGES_BROKEN_CPO_LOOKUP
126             template
127             friend RANGES_CXX14_CONSTEXPR meta::if_c::value>
128             swap(tagged &x, tagged &y)
129             noexcept(is_nothrow_swappable::value)
130             {
131             x.swap(y);
132             }
133             #endif
134             };
135              
136             #if RANGES_BROKEN_CPO_LOOKUP
137             namespace _tagged_
138             {
139             template
140             RANGES_CXX14_CONSTEXPR meta::if_c::value>
141             swap(tagged &x, tagged &y)
142             noexcept(is_nothrow_swappable::value)
143             {
144             x.swap(y);
145             }
146             }
147             #endif
148              
149             template
150             auto get(tagged &t)
151             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
152             (
153             ranges::detail::adl_get(static_cast(t))
154             )
155             template
156             auto get(tagged const &t)
157             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
158             (
159             ranges::detail::adl_get(static_cast(t))
160             )
161             template
162             auto get(tagged &&t)
163             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
164             (
165             ranges::detail::adl_get(static_cast(t))
166             )
167             template
168             void get(tagged const &&) = delete;
169              
170             template
171             auto get(tagged &t)
172             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
173             (
174             ranges::detail::adl_get(static_cast(t))
175             )
176             template
177             auto get(tagged const &t)
178             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
179             (
180             ranges::detail::adl_get(static_cast(t))
181             )
182             template
183             auto get(tagged &&t)
184             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
185             (
186             ranges::detail::adl_get(static_cast(t))
187             )
188             template
189             void get(tagged const &&) = delete;
190              
191             template
192             using tagged_pair =
193             tagged, detail::tag_elem>,
194             detail::tag_spec, detail::tag_spec>;
195              
196             template
197             typename R = tagged_pair), Tag2(bind_element_t)>>
198             constexpr R make_tagged_pair(T1 && t1, T2 && t2)
199             noexcept(std::is_nothrow_constructible::value)
200             {
201             return {static_cast(t1), static_cast(t2)};
202             }
203             }
204             }
205              
206             #define RANGES_DEFINE_TAG_SPECIFIER(NAME) \
207             namespace tag \
208             { \
209             struct NAME \
210             { \
211             template \
212             class getter : public Next \
213             { \
214             protected: \
215             ~getter() = default; \
216             public: \
217             getter() = default; \
218             getter(getter &&) = default; \
219             getter(getter const &) = default; \
220             using Next::Next; \
221             CONCEPT_REQUIRES(MoveConstructible()) \
222             constexpr getter(Untagged && that) \
223             noexcept(std::is_nothrow_move_constructible::value) \
224             : Next(detail::move(that)) \
225             {} \
226             CONCEPT_REQUIRES(CopyConstructible()) \
227             constexpr getter(Untagged const &that) \
228             noexcept(std::is_nothrow_copy_constructible::value) \
229             : Next(that) \
230             {} \
231             getter &operator=(getter &&) = default; \
232             getter &operator=(getter const &) = default; \
233             RANGES_CXX14_CONSTEXPR \
234             meta::_t> &NAME() & \
235             noexcept(noexcept( \
236             detail::adl_get(std::declval()))) \
237             { \
238             return detail::adl_get(static_cast(*this)); \
239             } \
240             RANGES_CXX14_CONSTEXPR \
241             meta::_t> &&NAME() && \
242             noexcept(noexcept( \
243             detail::adl_get(std::declval()))) \
244             { \
245             return detail::adl_get(static_cast(*this)); \
246             } \
247             constexpr \
248             meta::_t> const &NAME() const & \
249             noexcept(noexcept( \
250             detail::adl_get(std::declval()))) \
251             { \
252             return detail::adl_get(static_cast(*this)); \
253             } \
254             }; \
255             }; \
256             } \
257             /**/
258              
259             RANGES_DIAGNOSTIC_PUSH
260             RANGES_DIAGNOSTIC_IGNORE_MISMATCHED_TAGS
261              
262             namespace std
263             {
264             template
265             struct tuple_size< ::ranges::v3::tagged>
266             : tuple_size
267             {};
268              
269             template
270             struct tuple_element>
271             : tuple_element
272             {};
273             }
274              
275             RANGES_DIAGNOSTIC_POP
276              
277             #endif