You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

addressof.hpp 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /// \file
  2. // Range v3 library
  3. //
  4. // Copyright Andrey Diduh 2019
  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. #ifndef RANGES_V3_VIEW_ADDRESSOF_HPP
  14. #define RANGES_V3_VIEW_ADDRESSOF_HPP
  15. #include <type_traits>
  16. #include <utility>
  17. #include <meta/meta.hpp>
  18. #include <range/v3/utility/addressof.hpp>
  19. #include <range/v3/view/transform.hpp>
  20. #include <range/v3/view/view.hpp>
  21. namespace ranges
  22. {
  23. /// \addtogroup group-views
  24. /// @{
  25. namespace views
  26. {
  27. struct addressof_fn
  28. {
  29. private:
  30. struct take_address
  31. {
  32. template<typename V>
  33. constexpr V * operator()(V & value) const noexcept
  34. {
  35. return detail::addressof(value);
  36. }
  37. };
  38. public:
  39. CPP_template(typename Rng)( //
  40. requires viewable_range<Rng> && input_range<Rng> && //
  41. std::is_lvalue_reference<range_reference_t<Rng>>::value) //
  42. constexpr auto CPP_auto_fun(operator())(Rng && rng)(const)(
  43. return transform(all(static_cast<Rng &&>(rng)), take_address{}))
  44. };
  45. /// \relates addressof_fn
  46. /// \ingroup group-views
  47. RANGES_INLINE_VARIABLE(view<addressof_fn>, addressof)
  48. } // namespace views
  49. /// @}
  50. } // namespace ranges
  51. #endif // RANGES_V3_VIEW_ADDRESSOF_HPP