File tree 2 files changed +27
-4
lines changed
2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 36
36
// - define DEC_EXTERNAL_LIMITS to define by yourself DEC_MAX_INT32
37
37
// - define DEC_NO_CPP11 if your compiler does not support C++11
38
38
// - define DEC_ALLOW_SPACESHIP_OPER as 1 if your compiler supports spaceship operator
39
+ // - define DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE as 1 if you want to make default constructor trivial
40
+ // use with caution because default constructor will not initialize the object
39
41
// - define DEC_TYPE_LEVEL as 0 for strong typing (same precision required for both arguments),
40
42
// as 1 for allowing to mix lower or equal precision types
41
43
// as 2 for automatic rounding when different precision is mixed
@@ -685,14 +687,23 @@ class decimal {
685
687
};
686
688
687
689
#ifdef DEC_NO_CPP11
688
- decimal () {
689
- init (0 );
690
- }
690
+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
691
+ decimal () {
692
+ }
693
+ #else
694
+ decimal () {
695
+ init (0 );
696
+ }
697
+ #endif
691
698
decimal (const decimal &src) {
692
699
init (src);
693
700
}
694
701
#else
695
- decimal () noexcept : m_value(0 ) {}
702
+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
703
+ decimal () noexcept = default;
704
+ #else
705
+ decimal () noexcept : m_value(0 ) {}
706
+ #endif
696
707
decimal (const decimal &src) = default;
697
708
#endif
698
709
explicit decimal (uint value) {
Original file line number Diff line number Diff line change @@ -186,12 +186,24 @@ BOOST_AUTO_TEST_CASE(decimalFloatConstructorHighPrec) {
186
186
187
187
#ifndef DEC_NO_CPP11
188
188
BOOST_AUTO_TEST_CASE (trivialAndNoThrowConstructor) {
189
+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
190
+ BOOST_CHECK_EQUAL (std::is_trivial<dec::decimal<6 >>::value, true );
191
+ #else
189
192
BOOST_CHECK_EQUAL (std::is_trivial<dec::decimal<6 >>::value, false );
193
+ #endif
190
194
195
+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
196
+ BOOST_CHECK_EQUAL (std::is_trivially_constructible<dec::decimal<6 >>::value, true );
197
+ #else
191
198
BOOST_CHECK_EQUAL (std::is_trivially_constructible<dec::decimal<6 >>::value, false );
199
+ #endif
192
200
BOOST_CHECK_EQUAL (std::is_nothrow_constructible<dec::decimal<6 >>::value, true );
193
201
202
+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
203
+ BOOST_CHECK_EQUAL (std::is_trivially_default_constructible<dec::decimal<6 >>::value, true );
204
+ #else
194
205
BOOST_CHECK_EQUAL (std::is_trivially_default_constructible<dec::decimal<6 >>::value, false );
206
+ #endif
195
207
BOOST_CHECK_EQUAL (std::is_nothrow_default_constructible<dec::decimal<6 >>::value, true );
196
208
197
209
BOOST_CHECK_EQUAL (std::is_trivially_copy_constructible<dec::decimal<6 >>::value, true );
You can’t perform that action at this time.
0 commit comments