Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
libcxx/include/__utility/terminate_on_exception.h
- This file was copied from libcxx/include/__algorithm/any_of.h.
// -*- C++ -*- | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#ifndef _LIBCPP___ALGORITHM_ANY_OF_H | #ifndef _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H | ||||
#define _LIBCPP___ALGORITHM_ANY_OF_H | #define _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H | ||||
#include <__config> | #include <__config> | ||||
#include <exception> | |||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||||
# pragma GCC system_header | # pragma GCC system_header | ||||
#endif | #endif | ||||
_LIBCPP_BEGIN_NAMESPACE_STD | _LIBCPP_BEGIN_NAMESPACE_STD | ||||
template <class _InputIterator, class _Predicate> | template <class _Func> | ||||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | _LIBCPP_HIDE_FROM_ABI auto __terminate_on_exception(_Func __func) { | ||||
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | #ifndef _LIBCPP_NO_EXCEPTIONS | ||||
for (; __first != __last; ++__first) | try { | ||||
if (__pred(*__first)) | #endif | ||||
return true; | return __func(); | ||||
return false; | #ifndef _LIBCPP_NO_EXCEPTIONS | ||||
} catch (...) { | |||||
std::terminate(); | |||||
} | |||||
#endif | |||||
} | } | ||||
_LIBCPP_END_NAMESPACE_STD | _LIBCPP_END_NAMESPACE_STD | ||||
#endif // _LIBCPP___ALGORITHM_ANY_OF_H | #endif // _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H |