chars_format.h 2.1 KB

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