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());
#define KJ_CONSTEXPR(...) constexpr
#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.
......
......@@ -761,7 +761,7 @@ kj::Array<HashBucket> rehash(kj::ArrayPtr<const HashBucket> oldBuckets, size_t t
template <typename Callbacks>
class HashIndex {
public:
HashIndex() = default;
HashIndex() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params>
HashIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {}
......@@ -1299,7 +1299,7 @@ inline BTreeImpl::Iterator BTreeImpl::end() const {
template <typename Callbacks>
class TreeIndex {
public:
TreeIndex() = default;
TreeIndex() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params>
TreeIndex(Params&&... params): cb(kj::fwd<Params>(params)...) {}
......
......@@ -93,7 +93,7 @@ struct TupleElement {
// from a TupleElement for each element, which is more efficient than a recursive definition.
T value;
TupleElement() = default;
TupleElement() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
constexpr inline TupleElement(const T& value): value(value) {}
constexpr inline TupleElement(T&& value): value(kj::mv(value)) {}
};
......@@ -123,7 +123,7 @@ struct TupleImpl<Indexes<indexes...>, Types...>
static_assert(sizeof...(indexes) == sizeof...(Types), "Incorrect use of TupleImpl.");
TupleImpl() = default;
TupleImpl() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... Params>
inline TupleImpl(Params&&... params)
......@@ -153,7 +153,7 @@ class Tuple {
// The actual Tuple class (used for tuples of size other than 1).
public:
Tuple() = default;
Tuple() KJ_DEFAULT_CONSTRUCTOR_VS2015_BUGGY
template <typename... U>
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