xref: /llvm-project/libcxx/include/__iterator/empty.h (revision e99c4906e44ae3f921fa05356909d006cda8d954)
18517a26dSChristopher Di Bella // -*- C++ -*-
28517a26dSChristopher Di Bella //===----------------------------------------------------------------------===//
38517a26dSChristopher Di Bella //
48517a26dSChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
58517a26dSChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
68517a26dSChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
78517a26dSChristopher Di Bella //
88517a26dSChristopher Di Bella //===----------------------------------------------------------------------===//
98517a26dSChristopher Di Bella 
108517a26dSChristopher Di Bella #ifndef _LIBCPP___ITERATOR_EMPTY_H
118517a26dSChristopher Di Bella #define _LIBCPP___ITERATOR_EMPTY_H
128517a26dSChristopher Di Bella 
138517a26dSChristopher Di Bella #include <__config>
148517a26dSChristopher Di Bella #include <initializer_list>
158517a26dSChristopher Di Bella 
168517a26dSChristopher Di Bella #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
178517a26dSChristopher Di Bella #  pragma GCC system_header
188517a26dSChristopher Di Bella #endif
198517a26dSChristopher Di Bella 
208517a26dSChristopher Di Bella _LIBCPP_BEGIN_NAMESPACE_STD
218517a26dSChristopher Di Bella 
224f15267dSNikolas Klauser #if _LIBCPP_STD_VER >= 17
238517a26dSChristopher Di Bella 
248517a26dSChristopher Di Bella template <class _Cont>
25*83bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
26*83bc7b57SNikolas Klauser empty(const _Cont& __c) noexcept(noexcept(__c.empty())) -> decltype(__c.empty()) {
279783f28cSLouis Dionne   return __c.empty();
289783f28cSLouis Dionne }
298517a26dSChristopher Di Bella 
308517a26dSChristopher Di Bella template <class _Tp, size_t _Sz>
31*83bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(const _Tp (&)[_Sz]) noexcept {
329783f28cSLouis Dionne   return false;
339783f28cSLouis Dionne }
348517a26dSChristopher Di Bella 
358517a26dSChristopher Di Bella template <class _Ep>
36*83bc7b57SNikolas Klauser [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(initializer_list<_Ep> __il) noexcept {
379783f28cSLouis Dionne   return __il.size() == 0;
389783f28cSLouis Dionne }
398517a26dSChristopher Di Bella 
404f15267dSNikolas Klauser #endif // _LIBCPP_STD_VER >= 17
418517a26dSChristopher Di Bella 
428517a26dSChristopher Di Bella _LIBCPP_END_NAMESPACE_STD
438517a26dSChristopher Di Bella 
448517a26dSChristopher Di Bella #endif // _LIBCPP___ITERATOR_EMPTY_H
45