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.
 
 
 
 

71 lignes
2.0 KiB

  1. /*!
  2. * \file /utl/impl/concepts/iterators.h
  3. * \brief utl iterator concept support header
  4. *
  5. * Copyright (C) 2018 Christos Choutouridis
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation, either version 3
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #ifndef __utl_concepts_iterator_h__
  22. #define __utl_concepts_iterator_h__
  23. #include <utl/core/impl.h>
  24. #include <utl/concepts/defines.h>
  25. #include <utl/concepts/stl.h>
  26. /*!
  27. * \ingroup concepts
  28. * \defgroup iterators
  29. */
  30. //! @{
  31. namespace utl {
  32. #if CXX_CONCEPTS
  33. template <class I>
  34. _utlConcept WeaklyIncrementable =
  35. Semiregular<I> &&
  36. requires(I i) {
  37. { ++i } -> Same<I>&; // not required to be equality preserving
  38. i++; // not required to be equality preserving
  39. };
  40. #else
  41. namespace detail {
  42. template <typename I> using try_ppI = decltype (++(std::declval<I>()));
  43. template <typename I> using try_Ipp = decltype (std::declval<I>()++);
  44. }
  45. template <class I>
  46. _utlConcept WeaklyIncrementable =
  47. Semiregular<I>
  48. && Same<_ref_t<I>, meta::detected_t<detail::try_ppI, _ref_t<I>>>
  49. && meta::is_detected<detail::try_Ipp, _ref_t<I>>::value;
  50. #endif
  51. #if CXX_CONCEPTS
  52. template <class I>
  53. _utlConcept DeviceIterator =
  54. requires(I i) {
  55. { *i } -> auto&&; // Requires: i is dereferenceable
  56. } &&
  57. WeaklyIncrementable<I>;
  58. #else
  59. #endif
  60. }
  61. //! @}
  62. #endif /* __utl_concepts_iterator_h__ */