diff --git a/include/type_safe/strong_typedef.hpp b/include/type_safe/strong_typedef.hpp index cc284d0..c5560ec 100644 --- a/include/type_safe/strong_typedef.hpp +++ b/include/type_safe/strong_typedef.hpp @@ -13,6 +13,12 @@ #include #include +#ifdef _MSC_VER +# define TYPE_SAFE_MSC_EMPTY_BASES __declspec(empty_bases) +#else +# define TYPE_SAFE_MSC_EMPTY_BASES +#endif + namespace type_safe { /// A strong typedef emulation. @@ -198,7 +204,7 @@ namespace strong_typedef_op using void_t = typename make_void::type; template > - struct is_strong_typedef : std::false_type + struct TYPE_SAFE_MSC_EMPTY_BASES is_strong_typedef : std::false_type {}; template @@ -547,24 +553,24 @@ namespace strong_typedef_op } template - struct integer_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division, - modulo, - increment, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES integer_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division, + modulo, + increment, + decrement {}; template - struct floating_point_arithmetic : unary_plus, - unary_minus, - addition, - subtraction, - multiplication, - division + struct TYPE_SAFE_MSC_EMPTY_BASES floating_point_arithmetic : unary_plus, + unary_minus, + addition, + subtraction, + multiplication, + division {}; template @@ -589,10 +595,10 @@ namespace strong_typedef_op TYPE_SAFE_DETAIL_MAKE_STRONG_TYPEDEF_OP(bitwise_and, &) template - struct bitmask : complement, - bitwise_or, - bitwise_xor, - bitwise_and + struct TYPE_SAFE_MSC_EMPTY_BASES bitmask : complement, + bitwise_or, + bitwise_xor, + bitwise_and {}; template @@ -655,7 +661,8 @@ namespace strong_typedef_op }; template - struct iterator : dereference, increment + struct TYPE_SAFE_MSC_EMPTY_BASES iterator : dereference, + increment { using iterator_category = Category; using value_type = typename std::remove_cv::type; @@ -665,31 +672,31 @@ namespace strong_typedef_op }; template - struct input_iterator : iterator, - equality_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES input_iterator : iterator, + equality_comparison {}; template - struct output_iterator : iterator + struct TYPE_SAFE_MSC_EMPTY_BASES output_iterator : iterator {}; template - struct forward_iterator : input_iterator + struct TYPE_SAFE_MSC_EMPTY_BASES forward_iterator : input_iterator { using iterator_category = std::forward_iterator_tag; }; template - struct bidirectional_iterator : forward_iterator, - decrement + struct TYPE_SAFE_MSC_EMPTY_BASES bidirectional_iterator : forward_iterator, + decrement { using iterator_category = std::bidirectional_iterator_tag; }; template - struct random_access_iterator : bidirectional_iterator, - array_subscript, - relational_comparison + struct TYPE_SAFE_MSC_EMPTY_BASES random_access_iterator : bidirectional_iterator, + array_subscript, + relational_comparison { using iterator_category = std::random_access_iterator_tag; @@ -774,7 +781,7 @@ namespace strong_typedef_op /// Inherit from it in the `std::hash` specialization to make /// it hashable like the underlying type. See example/strong_typedef.cpp. template -struct hashable : std::hash> +struct TYPE_SAFE_MSC_EMPTY_BASES hashable : std::hash> { using underlying_type = type_safe::underlying_type; using underlying_hash = std::hash; @@ -787,4 +794,6 @@ struct hashable : std::hash> }; } // namespace type_safe +#undef TYPE_SAFE_MSC_EMPTY_BASES + #endif // TYPE_SAFE_STRONG_TYPEDEF_HPP_INCLUDED