return result;
}
+#ifdef BOOST_MSVC
+#pragma warning(disable:4521) // multiple copy constructors specified
+#endif
+
struct test_class
{
};
template<class Concept>
-struct make_arg_impl<any<Concept, _a> >
+struct make_arg_impl<any<Concept, _a>&>
{
- static any<Concept, _a> apply()
+ static any<Concept, _a>& apply()
{
- return any<Concept, _a>(
+ static any<Concept, _a> result(
test_class(),
make_binding< ::boost::mpl::map<
::boost::mpl::pair<_a, test_class>,
::boost::mpl::pair<_b, int>
> >());
+ return result;
}
};
template<class Concept>
-struct make_arg_impl<any<Concept, _b> >
+struct make_arg_impl<any<Concept, _b>&>
{
- static any<Concept, _b> apply()
+ static any<Concept, _b>& apply()
{
- return any<Concept, _b>(
+ static any<Concept, _b> result(
(int)id_int,
make_binding< ::boost::mpl::map<
::boost::mpl::pair<_a, test_class>,
::boost::mpl::pair<_b, int>
> >());
+ return result;
+ }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _a> >
+{
+ static any<Concept, _a> apply()
+ {
+ return make_arg_impl<any<Concept, _a>&>::apply();
+ }
+};
+
+template<class Concept>
+struct make_arg_impl<any<Concept, _b> >
+{
+ static any<Concept, _b> apply()
+ {
+ return make_arg_impl<any<Concept, _b>&>::apply();
}
};
return result;
}
};
+template<class T>
+struct make_arg_impl<const T&>
+{
+ static T& apply()
+ {
+ return make_arg_impl<T&>::apply();
+ }
+};
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
{
static T&& apply()
{
- static T result = make_arg_impl<T>::apply();
- return std::move(result);
+ return std::move(make_arg_impl<T&>::apply());
}
};
}
};
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+// We need copy_constructible in order to get an rvalue.
+#define CONSTRUCT_COMMON(p) common<p>
+#else
+// Don't include the copy constructor if we don't
+// need it, as it can hide the non-const copy constructor.
+#define CONSTRUCT_COMMON(p) destructible<p>, typeid_<p>
+#endif
+
#define TEST_CONSTRUCT(sig, args, expected_) \
{\
typedef ::boost::mpl::vector<\
- common<_a>, \
+ CONSTRUCT_COMMON(_a), \
common<_b>,\
- constructible<sig>\
+ constructible<sig>,\
+ extra\
> C;\
std::vector<int> result = tester<C, void args>::apply();\
std::vector<int> expected = make_vector expected_;\
expected.begin(), expected.end());\
}
-BOOST_AUTO_TEST_CASE(test_default)
+typedef ::boost::mpl::vector<
+ ::boost::mpl::vector<>,
+ ::boost::type_erasure::relaxed
+> maybe_relaxed;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_default, extra, maybe_relaxed)
{
TEST_CONSTRUCT(_a(), (binding<C>), ());
TEST_CONSTRUCT(_a(), (binding<C>&), ());
}
// test all forms of direct construction that take 1 argument
-BOOST_AUTO_TEST_CASE(test_construct1)
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_construct1, extra, maybe_relaxed)
{
// construction from int
TEST_CONSTRUCT(_a(int&), (binding<C>, int&), (lvalue | id_int));
// Test same any type
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
// ambiguous with the copy constructor in C++03
TEST_CONSTRUCT(_a(_a&), (any<C, _a>&), (lvalue | id_copy));
TEST_CONSTRUCT(_a(_a&), (binding<C>, any<C, _a>&), (lvalue | id_copy));
TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, any<C, _a>&), (const_lvalue | id_copy));
TEST_CONSTRUCT(_a(const _a&), (const binding<C>&, const any<C, _a>&), (const_lvalue | id_copy));
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
TEST_CONSTRUCT(_a(_a&&), (any<C, _a>), (rvalue | id_copy));
TEST_CONSTRUCT(_a(_b), (const binding<C>&, any<C, _b>&), (rvalue | id_int));
TEST_CONSTRUCT(_a(_b), (const binding<C>&, const any<C, _b>&), (rvalue | id_int));
-#ifndef BOOST_NO_FUNCTION_REFERENCE_QUALIFIERS
+#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
TEST_CONSTRUCT(_a(_b&&), (any<C, _b>), (rvalue | id_int));
}
// test constructors with 2 parameters
-BOOST_AUTO_TEST_CASE(test_construct2)
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_construct2, extra, maybe_relaxed)
{
TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int), (rvalue | id_int, rvalue | id_int));
TEST_CONSTRUCT(_a(int, int), (binding<C>, int, int&), (rvalue | id_int, rvalue | id_int));