Micro template library A library for building device drivers
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

65 lignes
2.3 KiB

  1. /*!
  2. * \file container/range.h
  3. * \brief
  4. * A plain definition of a range struct with agregate initialization
  5. * and begin-end pairs.
  6. *
  7. * \copyright Copyright (C) 2021 Christos Choutouridis <christos@choutouridis.net>
  8. *
  9. * <dl class=\"section copyright\"><dt>License</dt><dd>
  10. * The MIT License (MIT)
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13. * of this software and associated documentation files (the "Software"), to deal
  14. * in the Software without restriction, including without limitation the rights
  15. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. * copies of the Software, and to permit persons to whom the Software is
  17. * furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included in all
  20. * copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. * </dd></dl>
  30. */
  31. #ifndef utl_container_range_h__
  32. #define utl_container_range_h__
  33. #include <utl/core/impl.h>
  34. namespace utl {
  35. /*!
  36. * \brief
  37. * A plain definition of a range struct with begin-end pairs.
  38. *
  39. * \tparam Iter_t The iterator type of the range
  40. */
  41. template <typename Iter_t>
  42. struct range {
  43. Iter_t b{}, e{};
  44. // range () = default;
  45. // range (const Iter_t& first, const Iter_t& last) noexcept :
  46. // b(first), e(last) { }
  47. // range (Iter_t first, Iter_t last) noexcept :
  48. // b(first), e(last) { }
  49. Iter_t begin() { return b; }
  50. const Iter_t begin() const { return b; }
  51. const Iter_t cbegin() const { return b; }
  52. Iter_t end() { return e; }
  53. const Iter_t end() const { return e; }
  54. const Iter_t cend() const { return e; }
  55. };
  56. } // namespace utl;
  57. #endif /* utl_container_range_h__ */