Fixes for Ticket #7569 ( Compile Error using BOOST_FUSION_DEFINE_STRUCT_INLINE with VC10 and GCC <4.5 )

[SVN r81165]
This commit is contained in:
Joel de Guzman
2012-11-04 00:18:41 +00:00
parent d01148d339
commit cfbbba272e
3 changed files with 183 additions and 39 deletions

View File

@ -27,6 +27,17 @@ struct cls
)
};
template <typename = int>
struct tpl_cls
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(X)(Y),
point,
(X, x)
(Y, y)
)
};
namespace ns
{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), s, (M, m))
@ -34,13 +45,11 @@ namespace ns
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE((M), empty_struct, )
}
int
main()
template <typename Point>
void run_test()
{
using namespace boost::fusion;
typedef cls::point<int, int> point;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
@ -51,8 +60,8 @@ main()
}
{
BOOST_MPL_ASSERT_NOT((traits::is_view<point>));
point p(123, 456);
BOOST_MPL_ASSERT_NOT((traits::is_view<Point>));
Point p(123, 456);
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
@ -63,8 +72,8 @@ main()
at_c<1>(p) = 9;
BOOST_TEST(p == make_vector(6, 9));
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<point>::value);
BOOST_STATIC_ASSERT(boost::fusion::result_of::size<Point>::value == 2);
BOOST_STATIC_ASSERT(!boost::fusion::result_of::empty<Point>::value);
BOOST_TEST(front(p) == 6);
BOOST_TEST(back(p) == 9);
@ -72,7 +81,7 @@ main()
{
vector<int, float> v1(4, 2);
point v2(5, 3);
Point v2(5, 3);
vector<long, double> v3(5, 4);
BOOST_TEST(v1 < v2);
BOOST_TEST(v1 <= v2);
@ -85,15 +94,15 @@ main()
}
{
// conversion from point to vector
point p(5, 3);
// conversion from Point to vector
Point p(5, 3);
vector<int, long> v(p);
v = p;
}
{
// conversion from point to list
point p(5, 3);
// conversion from Point to list
Point p(5, 3);
list<int, long> l(p);
l = p;
}
@ -109,13 +118,20 @@ main()
{
point p = make_list(5,3);
Point p = make_list(5,3);
BOOST_TEST(p == make_vector(5,3));
p = make_list(3,5);
BOOST_TEST(p == make_vector(3,5));
}
}
int
main()
{
run_test<cls::point<int, int> >(); // test non-template enclosing class
run_test<tpl_cls<>::point<int, int> >(); // test template enclosing class
return boost::report_errors();
}