data.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP___ITERATOR_DATA_H
  10. #define _LIBCPP___ITERATOR_DATA_H
  11. #include <__config>
  12. #include <cstddef>
  13. #include <initializer_list>
  14. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  15. # pragma GCC system_header
  16. #endif
  17. _LIBCPP_BEGIN_NAMESPACE_STD
  18. #if _LIBCPP_STD_VER >= 17
  19. template <class _Cont> constexpr
  20. _LIBCPP_INLINE_VISIBILITY
  21. auto data(_Cont& __c)
  22. _NOEXCEPT_(noexcept(__c.data()))
  23. -> decltype (__c.data())
  24. { return __c.data(); }
  25. template <class _Cont> constexpr
  26. _LIBCPP_INLINE_VISIBILITY
  27. auto data(const _Cont& __c)
  28. _NOEXCEPT_(noexcept(__c.data()))
  29. -> decltype (__c.data())
  30. { return __c.data(); }
  31. template <class _Tp, size_t _Sz>
  32. _LIBCPP_INLINE_VISIBILITY
  33. constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
  34. template <class _Ep>
  35. _LIBCPP_INLINE_VISIBILITY
  36. constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
  37. #endif
  38. _LIBCPP_END_NAMESPACE_STD
  39. #endif // _LIBCPP___ITERATOR_DATA_H