Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:45

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___CXX03___UTILITY_IS_VALID_RANGE_H
0010 #define _LIBCPP___CXX03___UTILITY_IS_VALID_RANGE_H
0011 
0012 #include <__cxx03/__algorithm/comp.h>
0013 #include <__cxx03/__config>
0014 #include <__cxx03/__type_traits/is_constant_evaluated.h>
0015 
0016 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0017 #  pragma GCC system_header
0018 #endif
0019 
0020 _LIBCPP_BEGIN_NAMESPACE_STD
0021 
0022 template <class _Tp>
0023 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
0024 __is_valid_range(const _Tp* __first, const _Tp* __last) {
0025   if (__libcpp_is_constant_evaluated()) {
0026     // If this is not a constant during constant evaluation, that is because __first and __last are not
0027     // part of the same allocation. If they are part of the same allocation, we must still make sure they
0028     // are ordered properly.
0029     return __builtin_constant_p(__first <= __last) && __first <= __last;
0030   }
0031 
0032   return !__less<>()(__last, __first);
0033 }
0034 
0035 _LIBCPP_END_NAMESPACE_STD
0036 
0037 #endif // _LIBCPP___CXX03___UTILITY_IS_VALID_RANGE_H