File Coverage

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


line stmt bran cond sub pod time code
1             /// \file
2             // Range v3 library
3             //
4             // Copyright Eric Niebler 2014-present
5             //
6             // Use, modification and distribution is subject to the
7             // Boost Software License, Version 1.0. (See accompanying
8             // file LICENSE_1_0.txt or copy at
9             // http://www.boost.org/LICENSE_1_0.txt)
10             //
11             // Project home: https://github.com/ericniebler/range-v3
12             //
13              
14             #ifndef RANGES_V3_SIZE_HPP
15             #define RANGES_V3_SIZE_HPP
16              
17             #include
18             #include
19             #include
20             #include
21              
22             namespace ranges
23             {
24             inline namespace v3
25             {
26             /// \addtogroup group-concepts
27             // Specialize this if the default is wrong.
28             template
29             struct disable_sized_range : std::false_type {};
30              
31             /// \cond
32             namespace _size_
33             {
34             template
35             void size(T const &) = delete;
36              
37             #ifdef RANGES_WORKAROUND_MSVC_620035
38             void size();
39             #endif
40              
41             struct fn : iter_size_fn
42             {
43             private:
44             template
45             static constexpr std::size_t impl_(R (&)[N], int) noexcept
46             {
47             return N;
48             }
49              
50             // Prefer member if it returns Integral.
51             template
52             typename = meta::if_c()>,
53             typename N = decltype(aux::copy(std::declval().size())),
54             CONCEPT_REQUIRES_(Integral())>
55 319           static constexpr N impl_(R &r, int)
56 319           RANGES_AUTO_RETURN_NOEXCEPT
57             (
58             r.size()
59             )
60              
61             // Use ADL if it returns Integral.
62             template
63             typename = meta::if_c()>,
64             typename N = decltype(aux::copy(size(std::declval()))),
65             CONCEPT_REQUIRES_(Integral())>
66             static constexpr N impl_(R &r, long)
67             RANGES_AUTO_RETURN_NOEXCEPT
68             (
69             size(r)
70             )
71              
72             template
73             typename I = decltype(ranges::cbegin(std::declval())),
74             CONCEPT_REQUIRES_(ForwardIterator())>
75             static RANGES_CXX14_CONSTEXPR auto impl_(R &r, ...)
76             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
77             (
78             ranges::iter_size(ranges::cbegin(r), ranges::cend(r))
79             )
80              
81             public:
82             using iter_size_fn::operator();
83              
84             template
85 319           constexpr auto operator()(R &&r) const
86 319           RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
87             (
88             fn::impl_(r, 42)
89             )
90              
91             template
92             constexpr auto operator()(std::reference_wrapper ref) const
93             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
94             (
95             Fn()(ref.get())
96             )
97              
98             template
99             constexpr auto operator()(ranges::reference_wrapper ref) const
100             RANGES_DECLTYPE_AUTO_RETURN_NOEXCEPT
101             (
102             Fn()(ref.get())
103             )
104             };
105             }
106             /// \endcond
107              
108             /// \ingroup group-core
109             /// \return The result of an unqualified call to `size`
110             inline namespace CPOs
111             {
112             RANGES_INLINE_VARIABLE(_size_::fn, size)
113             }
114             }
115             }
116              
117             #endif