-// Copyright Louis Dionne 2013-2016
+// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <boost/hana/first.hpp>
#include <boost/hana/pair.hpp>
#include <boost/hana/second.hpp>
+
+#include <type_traits>
namespace hana = boost::hana;
explicit constexpr NoDefault(int) { }
};
+struct NoDefault_nonempty {
+ NoDefault_nonempty() = delete;
+ explicit constexpr NoDefault_nonempty(int k) : i(k) { }
+ int i;
+};
+
struct DefaultOnly {
DefaultOnly() = default;
DefaultOnly(DefaultOnly const&) = delete;
// make sure the default constructor is not instantiated when the
// members of the pair are not default-constructible
{
- hana::pair<NoDefault, NoDefault> p{NoDefault{1}, NoDefault{2}};
- (void)p;
+ using Pair1 = hana::pair<NoDefault, NoDefault>;
+ Pair1 p1{NoDefault{1}, NoDefault{2}};
+ static_assert(!std::is_default_constructible<Pair1>{}, "");
+
+ using Pair2 = hana::pair<NoDefault_nonempty, NoDefault_nonempty>;
+ Pair2 p2{NoDefault_nonempty{1}, NoDefault_nonempty{2}};
+ static_assert(!std::is_default_constructible<Pair2>{}, "");
}
// make sure it works when only the default constructor is defined