File tree Expand file tree Collapse file tree 5 files changed +42
-26
lines changed
Expand file tree Collapse file tree 5 files changed +42
-26
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ include::decimal/generic_decimal.adoc[]
2020include::decimal/decimal32.adoc[]
2121include::decimal/decimal64.adoc[]
2222include::decimal/decimal128.adoc[]
23+ include::decimal/literals.adoc[]
2324include::decimal/numbers.adoc[]
2425include::decimal/cmath.adoc[]
2526include::decimal/cstdlib.adoc[]
Original file line number Diff line number Diff line change @@ -83,14 +83,6 @@ explicit constexpr operator std::bfloat16_t() const noexcept;
8383explicit constexpr operator decimal32() const noexcept;
8484explicit constexpr operator decimal64() const noexcept;
8585
86- // Literals
87- constexpr auto operator "" _DL(const char* str) -> decimal128
88- constexpr auto operator "" _dl(const char* str) -> decimal128
89- constexpr auto operator "" _DL(unsigned long long v) -> decimal128
90- constexpr auto operator "" _dl(unsigned long long v) -> decimal128
91- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _DL(long double v) -> decimal128
92- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _dl(long double v) -> decimal128
93-
9486} //namespace decimal
9587} //namespace boost
9688
Original file line number Diff line number Diff line change @@ -83,16 +83,6 @@ explicit constexpr operator std::bfloat16_t() const noexcept;
8383explicit constexpr operator decimal64() const noexcept;
8484explicit constexpr operator decimal128() const noexcept;
8585
86- // Literals
87- constexpr auto operator "" _DF(const char* str) -> decimal32
88- constexpr auto operator "" _df(const char* str) -> decimal32
89-
90- constexpr auto operator "" _DF(unsigned long long v) -> decimal32
91- constexpr auto operator "" _dF(unsigned long long v) -> decimal32
92-
93- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _DF(long double v) -> decimal32
94- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _dF(long double v) -> decimal32
95-
9686} //namespace decimal
9787} //namespace boost
9888
Original file line number Diff line number Diff line change @@ -83,14 +83,6 @@ explicit constexpr operator std::bfloat16_t() const noexcept;
8383explicit constexpr operator decimal32() const noexcept;
8484explicit constexpr operator decimal128() const noexcept;
8585
86- // Literals
87- constexpr auto operator "" _DD(const char* str) -> decimal64
88- constexpr auto operator "" _dd(const char* str) -> decimal64
89- constexpr auto operator "" _DD(unsigned long long v) -> decimal64
90- constexpr auto operator "" _dd(unsigned long long v) -> decimal64
91- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _DD(long double v) -> decimal64
92- BOOST_DECIMAL_CXX20_CONSTEXPR auto operator "" _dd(long double v) -> decimal64
93-
9486} //namespace decimal
9587} //namespace boost
9688
Original file line number Diff line number Diff line change 1+ ////
2+ Copyright 2023 Matt Borland
3+ Distributed under the Boost Software License, Version 1.0.
4+ https://www.boost.org/LICENSE_1_0.txt
5+ ////
6+
7+ [#literals]
8+ = Literals Support
9+ :idprefix: literals_
10+
11+ The following literals are offered to construct each of the types:
12+
13+ [source, c++]
14+ ----
15+ namespace boost {
16+ namespace decimal {
17+
18+ constexpr auto operator "" _DF(const char* str) -> decimal32
19+ constexpr auto operator "" _df(const char* str) -> decimal32
20+
21+ constexpr auto operator "" _DF(unsigned long long v) -> decimal32
22+ constexpr auto operator "" _dF(unsigned long long v) -> decimal32
23+
24+ constexpr auto operator "" _DD(const char* str) -> decimal64
25+ constexpr auto operator "" _dd(const char* str) -> decimal64
26+
27+ constexpr auto operator "" _DD(unsigned long long v) -> decimal64
28+ constexpr auto operator "" _dd(unsigned long long v) -> decimal64
29+
30+ constexpr auto operator "" _DL(const char* str) -> decimal128
31+ constexpr auto operator "" _dl(const char* str) -> decimal128
32+
33+ constexpr auto operator "" _DL(unsigned long long v) -> decimal128
34+ constexpr auto operator "" _dl(unsigned long long v) -> decimal128
35+
36+ } //namespace decimal
37+ } //namespace boost
38+ ----
39+
40+ IMPORTANT: `0.2_DF` is equivalent to calling `decimal32{2, -1}` .
41+ These are different from calling `decimal32{0.2}` which converts from a floating-point value which may or may not be exactly represented.
You can’t perform that action at this time.
0 commit comments