Skip to content

Commit 2b5b8e0

Browse files
melak47JkarVN
authored andcommitted
Enable empty base class optimization on MSVC
...so that sizeof(RNG) matches expected values in tests
1 parent e5e1c1d commit 2b5b8e0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

include/pcg_random.hpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,18 @@
9494

9595
#ifdef _MSC_VER
9696
#define PCG_ALWAYS_INLINE __forceinline
97+
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190024210
98+
// available since VS 2015 Update 2/3
99+
#define PCG_EBO __declspec(empty_bases)
100+
#else
101+
#define PCG_EBO
102+
#endif
97103
#elif __GNUC__
98104
#define PCG_ALWAYS_INLINE __attribute__((always_inline))
105+
#define PCG_EBO
99106
#else
100107
#define PCG_ALWAYS_INLINE inline
108+
#define PCG_EBO
101109
#endif
102110

103111
/*
@@ -375,7 +383,7 @@ template <typename xtype, typename itype,
375383
bool output_previous = true,
376384
typename stream_mixin = oneseq_stream<itype>,
377385
typename multiplier_mixin = default_multiplier<itype> >
378-
class engine : protected output_mixin,
386+
class PCG_EBO engine : protected output_mixin,
379387
public stream_mixin,
380388
protected multiplier_mixin {
381389
protected:
@@ -1187,7 +1195,7 @@ struct xsl_mixin {
11871195

11881196

11891197
template <typename baseclass>
1190-
struct inside_out : private baseclass {
1198+
struct PCG_EBO inside_out : private baseclass {
11911199
inside_out() = delete;
11921200

11931201
typedef typename baseclass::result_type result_type;
@@ -1229,7 +1237,7 @@ struct inside_out : private baseclass {
12291237

12301238

12311239
template <bitcount_t table_pow2, bitcount_t advance_pow2, typename baseclass, typename extvalclass, bool kdd = true>
1232-
class extended : public baseclass {
1240+
class PCG_EBO extended : public baseclass {
12331241
public:
12341242
typedef typename baseclass::state_type state_type;
12351243
typedef typename baseclass::result_type result_type;

0 commit comments

Comments
 (0)