chars_format.h revision 1.1.1.1
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#if _LIBCPP_STD_VER > 14
23
24enum class _LIBCPP_ENUM_VIS chars_format
25{
26    scientific = 0x1,
27    fixed = 0x2,
28    hex = 0x4,
29    general = fixed | scientific
30};
31
32inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
33operator~(chars_format __x) {
34  return chars_format(~_VSTD::__to_underlying(__x));
35}
36
37inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
38operator&(chars_format __x, chars_format __y) {
39  return chars_format(_VSTD::__to_underlying(__x) &
40                      _VSTD::__to_underlying(__y));
41}
42
43inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
44operator|(chars_format __x, chars_format __y) {
45  return chars_format(_VSTD::__to_underlying(__x) |
46                      _VSTD::__to_underlying(__y));
47}
48
49inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format
50operator^(chars_format __x, chars_format __y) {
51  return chars_format(_VSTD::__to_underlying(__x) ^
52                      _VSTD::__to_underlying(__y));
53}
54
55inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
56operator&=(chars_format& __x, chars_format __y) {
57  __x = __x & __y;
58  return __x;
59}
60
61inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
62operator|=(chars_format& __x, chars_format __y) {
63  __x = __x | __y;
64  return __x;
65}
66
67inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
68operator^=(chars_format& __x, chars_format __y) {
69  __x = __x ^ __y;
70  return __x;
71}
72
73#endif // _LIBCPP_STD_VER > 14
74
75_LIBCPP_END_NAMESPACE_STD
76
77#endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H
78