Commit 3a184591 authored by Kenton Varda's avatar Kenton Varda

Work around VS2015 bug with zero-arg default constructors.

parent b03be9a3
...@@ -303,6 +303,14 @@ KJ_NORETURN(void unreachable()); ...@@ -303,6 +303,14 @@ KJ_NORETURN(void unreachable());
#define KJ_CONSTEXPR(...) constexpr #define KJ_CONSTEXPR(...) constexpr
#endif #endif
#if defined(_MSC_VER) && _MSC_VER < 1910
// TODO(msvc): Visual Studio 2015 mishandles declaring the no-arg constructor `= default` for
// certain template types -- it fails to call member constructors.
#define KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY {}
#else
#define KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY = default;
#endif
// ======================================================================================= // =======================================================================================
// Template metaprogramming helpers. // Template metaprogramming helpers.
......
...@@ -761,7 +761,7 @@ kj::Array<HashBucket> rehash(kj::ArrayPtr<const HashBucket> oldBuckets, size_t t ...@@ -761,7 +761,7 @@ kj::Array<HashBucket> rehash(kj::ArrayPtr<const HashBucket> oldBuckets, size_t t
template <typename Callbacks> template <typename Callbacks>
class HashIndex { class HashIndex {
public: public:
HashIndex() = default; HashIndex() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params> template <typename... Params>
HashIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {} HashIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {}
...@@ -1299,7 +1299,7 @@ inline BTreeImpl::Iterator BTreeImpl::end() const { ...@@ -1299,7 +1299,7 @@ inline BTreeImpl::Iterator BTreeImpl::end() const {
template <typename Callbacks> template <typename Callbacks>
class TreeIndex { class TreeIndex {
public: public:
TreeIndex() = default; TreeIndex() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params> template <typename... Params>
TreeIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {} TreeIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {}
......
...@@ -93,7 +93,7 @@ struct TupleElement { ...@@ -93,7 +93,7 @@ struct TupleElement {
// from a TupleElement for each element, which is more efficient than a recursive definition. // from a TupleElement for each element, which is more efficient than a recursive definition.
T value; T value;
TupleElement() = default; TupleElement() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
constexpr inline TupleElement(const T& value): value(value) {} constexpr inline TupleElement(const T& value): value(value) {}
constexpr inline TupleElement(T&& value): value(kj::mv(value)) {} constexpr inline TupleElement(T&& value): value(kj::mv(value)) {}
}; };
...@@ -123,7 +123,7 @@ struct TupleImpl<Indexes<indexes...>, Types...> ...@@ -123,7 +123,7 @@ struct TupleImpl<Indexes<indexes...>, Types...>
static_assert(sizeof...(indexes) == sizeof...(Types), "Incorrect use of TupleImpl."); static_assert(sizeof...(indexes) == sizeof...(Types), "Incorrect use of TupleImpl.");
TupleImpl() = default; TupleImpl() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params> template <typename... Params>
inline TupleImpl(Params&&... params) inline TupleImpl(Params&&... params)
...@@ -153,7 +153,7 @@ class Tuple { ...@@ -153,7 +153,7 @@ class Tuple {
// The actual Tuple class (used for tuples of size other than 1). // The actual Tuple class (used for tuples of size other than 1).
public: public:
Tuple() = default; Tuple() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... U> template <typename... U>
constexpr inline Tuple(Tuple<U...>&& other): impl(kj::mv(other)) {} constexpr inline Tuple(Tuple<U...>&& other): impl(kj::mv(other)) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment