chars_format.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 >= 17
  18. enum class chars_format { scientific = 0x1, fixed = 0x2, hex = 0x4, general = fixed | scientific };
  19. inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator~(chars_format __x) {
  20. return chars_format(~std::__to_underlying(__x));
  21. }
  22. inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator&(chars_format __x, chars_format __y) {
  23. return chars_format(std::__to_underlying(__x) & std::__to_underlying(__y));
  24. }
  25. inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator|(chars_format __x, chars_format __y) {
  26. return chars_format(std::__to_underlying(__x) | std::__to_underlying(__y));
  27. }
  28. inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator^(chars_format __x, chars_format __y) {
  29. return chars_format(std::__to_underlying(__x) ^ std::__to_underlying(__y));
  30. }
  31. inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
  32. operator&=(chars_format& __x, chars_format __y) {
  33. __x = __x & __y;
  34. return __x;
  35. }
  36. inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
  37. operator|=(chars_format& __x, chars_format __y) {
  38. __x = __x | __y;
  39. return __x;
  40. }
  41. inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
  42. operator^=(chars_format& __x, chars_format __y) {
  43. __x = __x ^ __y;
  44. return __x;
  45. }
  46. #endif // _LIBCPP_STD_VER >= 17
  47. _LIBCPP_END_NAMESPACE_STD
  48. #endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H