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 
10 #ifndef _LIBCPP___FORMAT_FORMAT_ERROR_H
11 #define _LIBCPP___FORMAT_FORMAT_ERROR_H
12 
13 #include <__config>
14 #include <stdexcept>
15 
16 #ifdef _LIBCPP_NO_EXCEPTIONS
17 #include <cstdlib>
18 #endif
19 
20 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21 #pragma GCC system_header
22 #endif
23 
24 _LIBCPP_PUSH_MACROS
25 #include <__undef_macros>
26 
27 _LIBCPP_BEGIN_NAMESPACE_STD
28 
29 #if _LIBCPP_STD_VER > 17
30 
31 class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error {
32 public:
format_error(const string & __s)33   _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s)
34       : runtime_error(__s) {}
format_error(const char * __s)35   _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
36       : runtime_error(__s) {}
37   virtual ~format_error() noexcept;
38 };
39 
40 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
__throw_format_error(const char * __s)41 __throw_format_error(const char* __s) {
42 #ifndef _LIBCPP_NO_EXCEPTIONS
43   throw format_error(__s);
44 #else
45   (void)__s;
46   _VSTD::abort();
47 #endif
48 }
49 
50 #endif //_LIBCPP_STD_VER > 17
51 
52 _LIBCPP_END_NAMESPACE_STD
53 
54 _LIBCPP_POP_MACROS
55 
56 #endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
57