This file is indexed.

/usr/include/range/v3/utility/box.hpp is in librange-v3-dev 0.3.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/// \file
// Range v3 library
//
//  Copyright Eric Niebler 2013-present
//  Copyright Casey Carter 2016
//
//  Use, modification and distribution is subject to the
//  Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)
//
// Project home: https://github.com/ericniebler/range-v3
//

#ifndef RANGES_V3_UTILITY_BOX_HPP
#define RANGES_V3_UTILITY_BOX_HPP

#include <utility>
#include <cstdlib>
#include <type_traits>
#include <meta/meta.hpp>
#include <range/v3/range_fwd.hpp>
#include <range/v3/utility/get.hpp>
#include <range/v3/utility/concepts.hpp>

namespace ranges
{
    inline namespace v3
    {
        /// \addtogroup group-utility Utility
        /// @{
        ///
        template<typename T>
        struct mutable_
        {
            mutable T value;
            CONCEPT_REQUIRES(std::is_default_constructible<T>::value)
            constexpr mutable_()
              : value{}
            {}
            constexpr explicit mutable_(T const &t)
              : value(t)
            {}
            constexpr explicit mutable_(T &&t)
              : value(detail::move(t))
            {}
            mutable_ const &operator=(T const &t) const
            {
                value = t;
                return *this;
            }
            mutable_ const &operator=(T &&t) const
            {
                value = detail::move(t);
                return *this;
            }
            constexpr operator T &() const &
            {
                return value;
            }
        };

        template<typename T, T v>
        struct constant
        {
            constant() = default;
            constexpr explicit constant(T const &)
            {}
            constant &operator=(T const &)
            {
                return *this;
            }
            constant const &operator=(T const &) const
            {
                return *this;
            }
            constexpr operator T() const
            {
                return v;
            }
            constexpr T exchange(T const &) const
            {
                return v;
            }
        };

        static_assert(std::is_trivial<constant<int, 0>>::value, "Expected constant to be trivial");

        /// \cond
        namespace detail
        {
            // "box" has three different implementations that store a T differently:
            enum class box_compress {
                none,       // Nothing special: get() returns a reference to a T member subobject
                ebo,        // Apply Empty Base Optimization: get() returns a reference to a T base subobject
                coalesce    // Coalesce all Ts into one T: get() returns a reference to a static T singleton
            };

            // Per N4582, lambda closures are *not*:
            // - aggregates             ([expr.prim.lambda]/4)
            // - default constructible  ([expr.prim.lambda]/p21)
            // - copy assignable        ([expr.prim.lambda]/p21)
            template<typename Fn>
            using could_be_lambda =
                meta::bool_<
                    !std::is_default_constructible<Fn>::value &&
                    !std::is_copy_assignable<Fn>::value>;

            template<typename>
            constexpr box_compress box_compression_(...)
            {
                return box_compress::none;
            }
            template<typename T, typename = meta::if_<
                meta::strict_and<std::is_empty<T>, meta::not_<detail::is_final<T>>
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 6 && __GNUC_MINOR__ < 2
                    // GCC 6.0 & 6.1 find empty lambdas' implicit conversion to function pointer
                    // when doing overload resolution for function calls. That causes hard errors.
                    // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71117
                    , meta::not_<could_be_lambda<T>>
#endif
                >>>
            constexpr box_compress box_compression_(long)
            {
                return box_compress::ebo;
            }
#ifndef _MSC_VER
            // MSVC pukes passing non-constant-expression objects to constexpr
            // functions, so do not coalesce.
            template<typename T, typename = meta::if_<
                meta::strict_and<std::is_empty<T>, std::is_trivial<T>, std::is_default_constructible<T>>>>
            constexpr box_compress box_compression_(int)
            {
                return box_compress::coalesce;
            }
#endif
            template<typename T>
            constexpr box_compress box_compression()
            {
                return box_compression_<T>(0);
            }
        }
        /// \endcond

        template<typename Element, typename Tag = void, detail::box_compress = detail::box_compression<Element>()>
        class box
        {
            Element value;
        public:
            CONCEPT_REQUIRES(std::is_default_constructible<Element>::value)
            constexpr box()
                noexcept(std::is_nothrow_default_constructible<Element>::value)
              : value{}
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && std::is_convertible<E, Element>::value)>
            constexpr box(E && e)
                noexcept(std::is_nothrow_constructible<Element, E>::value)
              : value(static_cast<E&&>(e))
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && !std::is_convertible<E, Element>::value)>
            constexpr explicit box(E && e)
                noexcept(std::is_nothrow_constructible<Element, E>::value)
              : value(static_cast<E&&>(e))
            {}

            RANGES_CXX14_CONSTEXPR Element &get() & noexcept
            {
                return value;
            }
            constexpr Element const &get() const & noexcept
            {
                return value;
            }
            RANGES_CXX14_CONSTEXPR Element &&get() && noexcept
            {
                return detail::move(value);
            }
        };

        template<typename Element, typename Tag>
        class box<Element, Tag, detail::box_compress::ebo>
          : Element
        {
        public:
            CONCEPT_REQUIRES(std::is_default_constructible<Element>::value)
            constexpr box()
                noexcept(std::is_nothrow_default_constructible<Element>::value)
              : Element{}
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && std::is_convertible<E, Element>::value)>
            constexpr box(E && e)
                noexcept(std::is_nothrow_constructible<Element, E>::value)
              : Element(static_cast<E&&>(e))
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && !std::is_convertible<E, Element>::value)>
            constexpr explicit box(E && e)
                noexcept(std::is_nothrow_constructible<Element, E>::value)
              : Element(static_cast<E&&>(e))
            {}

            RANGES_CXX14_CONSTEXPR Element &get() & noexcept
            {
                return *this;
            }
            constexpr Element const &get() const & noexcept
            {
                return *this;
            }
            RANGES_CXX14_CONSTEXPR Element &&get() && noexcept
            {
                return detail::move(*this);
            }
        };

        template<typename Element, typename Tag>
        class box<Element, Tag, detail::box_compress::coalesce>
        {
            static Element value;
        public:
            constexpr box() noexcept
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && std::is_convertible<E, Element>::value)>
            constexpr box(E &&) noexcept
            {}
            template<typename E,
                CONCEPT_REQUIRES_(std::is_constructible<Element, E>::value && !std::is_convertible<E, Element>::value)>
            constexpr explicit box(E &&) noexcept
            {}

            RANGES_CXX14_CONSTEXPR Element &get() & noexcept
            {
                return value;
            }
            constexpr Element const &get() const & noexcept
            {
                return value;
            }
            RANGES_CXX14_CONSTEXPR Element &&get() && noexcept
            {
                return detail::move(value);
            }
        };

        template<typename Element, typename Tag>
        Element box<Element, Tag, detail::box_compress::coalesce>::value;

        // Get by tag type
        template<typename Tag, typename Element, detail::box_compress BC>
        RANGES_CXX14_CONSTEXPR Element & get(box<Element, Tag, BC> & b) noexcept
        {
            return b.get();
        }

        template<typename Tag, typename Element, detail::box_compress BC>
        constexpr Element const & get(box<Element, Tag, BC> const & b) noexcept
        {
            return b.get();
        }

        template<typename Tag, typename Element, detail::box_compress BC>
        RANGES_CXX14_CONSTEXPR Element && get(box<Element, Tag, BC> && b) noexcept
        {
            return detail::move(b).get();
        }

        // Get by index
        template<std::size_t I, typename Element, detail::box_compress BC>
        RANGES_CXX14_CONSTEXPR Element & get(box<Element, meta::size_t<I>, BC> & b) noexcept
        {
            return b.get();
        }

        template<std::size_t I, typename Element, detail::box_compress BC>
        constexpr Element const & get(box<Element, meta::size_t<I>, BC> const & b) noexcept
        {
            return b.get();
        }

        template<std::size_t I, typename Element, detail::box_compress BC>
        RANGES_CXX14_CONSTEXPR Element && get(box<Element, meta::size_t<I>, BC> && b) noexcept
        {
            return detail::move(b).get();
        }
        /// @}
    }
}

#endif