|
Boost : |
From: troy d. straszheim (troy_at_[hidden])
Date: 2008-05-29 17:07:06
Hi again guys,
This one is easier.
Having applied the assign_to/construct patch, examples 4 and 6 compile fine,
but example5.cpp died on this:
example5.cpp:283: instantiated from here
../boost/trunk/boost/spirit/home/support/attribute_transform.hpp:144: error:
ambiguous class template instantiation for 'boost::spirit::traits
::strip_single_element_sequence<
boost::fusion::vector<
boost::variant<
unsigned int, string, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_
>, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_
>, mpl_::bool_<false>
>'
../boost/trunk/boost/spirit/home/support/attribute_transform.hpp:144: error:
invalid use of incomplete type 'boost::spirit::traits
::strip_single_element_sequence<
boost::fusion::vector<
boost::variant<
unsigned int, string, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_
>, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_
>, mpl_::bool_<false>
>'
../boost/trunk/boost/spirit/home/support/attribute_transform.hpp:32: error:
declaration of 'boost::spirit::traits::strip_single_element_sequence<
boost::fusion::vector<
boost::variant<
unsigned int, string, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_, boost::detail::variant::void_
, boost::detail::variant::void_
>, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_
, boost::fusion::void_
>, mpl_::bool_<false>
>'
You just disambiguate via enable_if to get things building. Works on gcc4.2:
--- attribute_transform.hpp (revision 45915)
+++ attribute_transform.hpp (working copy)
@@ -11,6 +11,7 @@
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/component.hpp>
#include <boost/spirit/home/support/attribute_of.hpp>
+#include <boost/spirit/home/support/detail/values.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/is_sequence.hpp>
#include <boost/variant/variant_fwd.hpp>
@@ -25,16 +26,19 @@
namespace traits
{
+ using boost::spirit::detail::not_is_variant;
+
// Here, we provide policies for stripping single element fusion
// sequences. Add more specializations as needed.
- template <typename T, typename IsSequence>
+ template <typename T, typename IsSequence, typename Enable = void>
struct strip_single_element_sequence
{
typedef T type;
};
template <typename T>
- struct strip_single_element_sequence<fusion::vector<T>, mpl::false_>
+ struct strip_single_element_sequence<fusion::vector<T>, mpl::false_,
+ typename boost::enable_if<not_is_variant<T> >::type>
{
// Strips single element fusion vectors into its 'naked'
// form: vector<T> --> T
@@ -42,7 +46,8 @@
};
template <typename T>
- struct strip_single_element_sequence<fusion::vector<T>, mpl::true_>
+ struct strip_single_element_sequence<fusion::vector<T>, mpl::true_,
+ typename boost::enable_if<not_is_variant<T> >::type>
{
// Strips single element fusion vectors into its 'naked'
// form: vector<T> --> T, but does so only if T is not a fusion
Let me know if you just want a commit, (also for the other stuff).
There are a few more things like this around, I'll get after them. Thanks for a great
library (these little gotchas notwithstanding). I'm getting a
real kick out of all this, learning a lot... this code is *crazy*.
You guys have definitely raised the bar.
-t
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk