[switch] #include <boost/switch.hpp> gives compiler error under MSVC !

This is very strange given that boost::switch has been dwnloaded from Vault 1637 times as of now. But just including #include <boost/switch.hpp> Gives a compile error with MSVC 2008 under Vista: 1>boost/switch.hpp(62) : error C2785: 'R boost::switch_detail::forced_return(boost::remove_reference<T>::type *)' and 'void boost::switch_detail::forced_return(const void *)' have different return types 1> boost/switch.hpp(54) : see declaration of 'boost::switch_detail::forced_return' 1> boost/switch.hpp(62) : see declaration of 'boost::switch_detail::forced_return' 1>boost/switch.hpp(62) : error C2912: explicit specialization; 'void boost::switch_detail::forced_return<const void>(const void *)' is not a specialization of a function template 1>boost/switch.hpp(62) : fatal error C1903: unable to recover from previous error(s); stopping compilation I used Linux/gcc till now without problems, but I wonder there is something wrong in my MSVC setup because I would guess not all the 1637 people that have downloaded switch.zip use gcc. Marco

On Thu, Jun 5, 2008 at 8:15 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
Marco Costalba wrote:
This is very strange given that boost::switch has been dwnloaded from Vault 1637 times as of now.
Use the version in the sandbox.
Thanks it worked. Marco

On Thu, Jun 5, 2008 at 10:08 PM, Marco Costalba <mcostalba@gmail.com> wrote:
On Thu, Jun 5, 2008 at 8:15 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
Marco Costalba wrote:
This is very strange given that boost::switch has been dwnloaded from Vault 1637 times as of now.
Use the version in the sandbox.
Thanks it worked.
Well, almost worked ;-) Indeed I reordered the includes in alphabetical order from #include <boost/control/switch.hpp> #include <boost/control/case.hpp> to #include <boost/control/case.hpp> #include <boost/control/switch.hpp> and this is the result (under gcc) ../../../../boost_1_35_0/boost/control/case.hpp: In function 'R boost::control::switch_(N, boost::control::expression_template_case_t<boost::control::restrict_case_t<boost::control::case_group_t<boost::mpl::range_c<T, low, high>, F> > >)': ../../../../boost_1_35_0/boost/control/case.hpp:191: error: expected initializer before '<' token ../../../../boost_1_35_0/boost/control/case.hpp:192: error: 'default_construct' is not a member of 'boost::control::switch_detail' ../../../../boost_1_35_0/boost/control/case.hpp:192: error: expected primary-expression before '>' token ../../../../boost_1_35_0/boost/control/case.hpp:192: error: 'default_' was not declared in this scope ../../../../boost_1_35_0/boost/control/case.hpp:193: error: 'impl' has not been declared ../../../../boost_1_35_0/boost/control/case.hpp:193: error: expected primary-expression before ',' token ../../../../boost_1_35_0/boost/control/case.hpp:193: error: expected primary-expression before ',' token It happens that following code in case.hpp template<class R, class N, class T, T low, T high, class F> inline R switch_(N n, expression_template_case_t ----stripped--- typedef switch_detail::range_switch_impl<high - low> impl; switch_detail::default_construct<R> default_; return(impl::template apply<R, T, low, high>(n, cases.get().get().get(), default_)); } needs definitions in switch.hpp Marco

AMDG Marco Costalba wrote:
Well, almost worked ;-)
Indeed I reordered the includes in alphabetical order from
#include <boost/control/switch.hpp> #include <boost/control/case.hpp>
to
#include <boost/control/case.hpp> #include <boost/control/switch.hpp>
I've added a forward declaration. In Christ, Steven Watanabe

On Fri, Jun 6, 2008 at 3:29 AM, Steven Watanabe <watanabesj@gmail.com> wrote:
I've added a forward declaration.
You may need to add another one: // N is the number of cases not including the default template<int N> struct range_switch_impl; +template<class R> +struct default_construct; + struct empty_set { template<class T> static char lookup(T); };
participants (2)
-
Marco Costalba
-
Steven Watanabe