File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 3636// - define DEC_EXTERNAL_LIMITS to define by yourself DEC_MAX_INT32
3737// - define DEC_NO_CPP11 if your compiler does not support C++11
3838// - 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
3941// - define DEC_TYPE_LEVEL as 0 for strong typing (same precision required for both arguments),
4042// as 1 for allowing to mix lower or equal precision types
4143// as 2 for automatic rounding when different precision is mixed
@@ -685,14 +687,23 @@ class decimal {
685687 };
686688
687689#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
691698 decimal (const decimal &src) {
692699 init (src);
693700 }
694701#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
696707 decimal (const decimal &src) = default;
697708#endif
698709 explicit decimal (uint value) {
Original file line number Diff line number Diff line change @@ -186,12 +186,24 @@ BOOST_AUTO_TEST_CASE(decimalFloatConstructorHighPrec) {
186186
187187#ifndef DEC_NO_CPP11
188188BOOST_AUTO_TEST_CASE (trivialAndNoThrowConstructor) {
189+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
190+ BOOST_CHECK_EQUAL (std::is_trivial<dec::decimal<6 >>::value, true );
191+ #else
189192 BOOST_CHECK_EQUAL (std::is_trivial<dec::decimal<6 >>::value, false );
193+ #endif
190194
195+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
196+ BOOST_CHECK_EQUAL (std::is_trivially_constructible<dec::decimal<6 >>::value, true );
197+ #else
191198 BOOST_CHECK_EQUAL (std::is_trivially_constructible<dec::decimal<6 >>::value, false );
199+ #endif
192200 BOOST_CHECK_EQUAL (std::is_nothrow_constructible<dec::decimal<6 >>::value, true );
193201
202+ #ifdef DEC_TRIVIAL_DEFAULT_CONSTRUCTIBLE
203+ BOOST_CHECK_EQUAL (std::is_trivially_default_constructible<dec::decimal<6 >>::value, true );
204+ #else
194205 BOOST_CHECK_EQUAL (std::is_trivially_default_constructible<dec::decimal<6 >>::value, false );
206+ #endif
195207 BOOST_CHECK_EQUAL (std::is_nothrow_default_constructible<dec::decimal<6 >>::value, true );
196208
197209 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