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___CHARCONV_CHARS_FORMAT_H 11 #define _LIBCPP___CHARCONV_CHARS_FORMAT_H 12 13 #include <__config> 14 #include <__utility/to_underlying.h> 15 16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 17 # pragma GCC system_header 18 #endif 19 20 _LIBCPP_BEGIN_NAMESPACE_STD 21 22 #ifndef _LIBCPP_CXX03_LANG 23 24 enum class _LIBCPP_ENUM_VIS chars_format 25 { 26 scientific = 0x1, 27 fixed = 0x2, 28 hex = 0x4, 29 general = fixed | scientific 30 }; 31 32 inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format 33 operator~(chars_format __x) { 34 return chars_format(~_VSTD::__to_underlying(__x)); 35 } 36 37 inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format 38 operator&(chars_format __x, chars_format __y) { 39 return chars_format(_VSTD::__to_underlying(__x) & 40 _VSTD::__to_underlying(__y)); 41 } 42 43 inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format 44 operator|(chars_format __x, chars_format __y) { 45 return chars_format(_VSTD::__to_underlying(__x) | 46 _VSTD::__to_underlying(__y)); 47 } 48 49 inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format 50 operator^(chars_format __x, chars_format __y) { 51 return chars_format(_VSTD::__to_underlying(__x) ^ 52 _VSTD::__to_underlying(__y)); 53 } 54 55 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& 56 operator&=(chars_format& __x, chars_format __y) { 57 __x = __x & __y; 58 return __x; 59 } 60 61 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& 62 operator|=(chars_format& __x, chars_format __y) { 63 __x = __x | __y; 64 return __x; 65 } 66 67 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& 68 operator^=(chars_format& __x, chars_format __y) { 69 __x = __x ^ __y; 70 return __x; 71 } 72 73 #endif // _LIBCPP_CXX03_LANG 74 75 _LIBCPP_END_NAMESPACE_STD 76 77 #endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H 78