
Would someone have a fit if something like this were added to boost/mpl ? Robert Ramey //-------------------------------------------------------------------------- --- // boost/mpl/apply_if.hpp header file // See http://www.boost.org for updates, documentation, and revision history. //-------------------------------------------------------------------------- --- // // Copyright (c) 2004 // Robert Ramey // // Permission to use, copy, modify, distribute and sell this software // and its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appears in all copies and // that both the copyright notice and this permission notice appear in // supporting documentation. No representations are made about the // suitability of this software for any purpose. It is provided "as is" // without express or implied warranty. // apply_if is deprecated. Use eval_if instead. This is only included // to support older code like spirit 1.6 #ifndef BOOST_MPL_APPLY_IF_HPP_INCLUDED #define BOOST_MPL_APPLY_IF_HPP_INCLUDED #include "boost/mpl/eval_if.hpp" namespace boost { namespace mpl { template< typename C , typename F1 , typename F2 > struct apply_if { typedef BOOST_DEDUCED_TYPENAME eval_if<C,F1,F2>::type type; }; // (almost) copy & paste in order to save one more // recursively nested template instantiation to user template< bool C , typename F1 , typename F2 > struct apply_if_c { typedef BOOST_DEDUCED_TYPENAME eval_if_c<C,F1,F2>::type type; }; } // namespace mpl } // namespace boost #endif // BOOST_MPL_APPLY_IF_HPP_INCLUDED

"Robert Ramey" <ramey@rrsd.com> wrote in message news:20040913173738.24EAC3123A@acme.west.net...
Would someone have a fit if something like this were added to boost/mpl ?
template< typename C , typename F1 , typename F2 > struct apply_if { typedef BOOST_DEDUCED_TYPENAME eval_if<C,F1,F2>::type type; };
How about template< typename C , typename F1 , typename F2 > struct apply_if : eval_if<C,F1,F2> { }; ? Jonathan

"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"Robert Ramey" <ramey@rrsd.com> wrote in message news:20040913173738.24EAC3123A@acme.west.net...
Would someone have a fit if something like this were added to boost/mpl ?
template< typename C , typename F1 , typename F2 > struct apply_if { typedef BOOST_DEDUCED_TYPENAME eval_if<C,F1,F2>::type type; };
How about
template< typename C , typename F1 , typename F2 > struct apply_if : eval_if<C,F1,F2> { };
Metafunction forwarding confuses some old broken compilers. Robert's version is a bit more conservative. But, really, how hard can a global search/replace be? Or is Spirit 1.6.1 archived? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams writes:
"Jonathan Turkanis" <technews@kangaroologic.com> writes:
"Robert Ramey" <ramey@rrsd.com> wrote in message news:20040913173738.24EAC3123A@acme.west.net...
Would someone have a fit if something like this were added to boost/mpl ?
template< typename C , typename F1 , typename F2 > struct apply_if { typedef BOOST_DEDUCED_TYPENAME eval_if<C,F1,F2>::type type; };
How about
template< typename C , typename F1 , typename F2 > struct apply_if : eval_if<C,F1,F2> { };
Metafunction forwarding confuses some old broken compilers. Robert's version is a bit more conservative.
But, really, how hard can a global search/replace be? Or is Spirit 1.6.1 archived?
No, it's not. Or, to be exact, the latest 1.6.x version which we are supposed to compile against is not -- http://article.gmane.org/gmane.comp.parsers.spirit.devel/1964. I'd _much_ prefer to have this fixed by search & replace, more so because it'd have to be done eventually sooner or later anyway, if Spirit 1.6.x is meant to live past this release. -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
But, really, how hard can a global search/replace be? Or is Spirit 1.6.1 archived?
No, it's not. Or, to be exact, the latest 1.6.x version which we are supposed to compile against is not -- http://article.gmane.org/gmane.comp.parsers.spirit.devel/1964.
I'd _much_ prefer to have this fixed by search & replace, more so because it'd have to be done eventually sooner or later anyway, if Spirit 1.6.x is meant to live past this release.
I agree 100%. I'd appreciate it if someone could do the patch. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

Joel de Guzman writes:
Aleksey Gurtovoy wrote:
But, really, how hard can a global search/replace be? Or is Spirit 1.6.1 archived?
No, it's not. Or, to be exact, the latest 1.6.x version which we are supposed to compile against is not -- http://article.gmane.org/gmane.comp.parsers.spirit.devel/1964.
I'd _much_ prefer to have this fixed by search & replace, more so because it'd have to be done eventually sooner or later anyway, if Spirit 1.6.x is meant to live past this release.
I agree 100%. I'd appreciate it if someone could do the patch.
Fixed in the SPIRIT_1_6 branch. [Aside: there was just a single "apply_if.hpp" include, and that one turned out to be redundant; so much for all the FUD.] -- Aleksey Gurtovoy MetaCommunications Engineering

Aleksey Gurtovoy wrote:
Joel de Guzman writes:
Aleksey Gurtovoy wrote:
But, really, how hard can a global search/replace be? Or is Spirit 1.6.1 archived?
No, it's not. Or, to be exact, the latest 1.6.x version which we are supposed to compile against is not -- http://article.gmane.org/gmane.comp.parsers.spirit.devel/1964.
I'd _much_ prefer to have this fixed by search & replace, more so because it'd have to be done eventually sooner or later anyway, if Spirit 1.6.x is meant to live past this release.
I agree 100%. I'd appreciate it if someone could do the patch.
Fixed in the SPIRIT_1_6 branch.
Thanks Aleksey ! -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

On 09/13/2004 12:37 PM, Robert Ramey wrote:
Would someone have a fit if something like this were added to boost/mpl ? [snip] // apply_if is deprecated. Use eval_if instead. This is only included // to support older code like spirit 1.6
#ifndef BOOST_MPL_APPLY_IF_HPP_INCLUDED #define BOOST_MPL_APPLY_IF_HPP_INCLUDED
#include "boost/mpl/eval_if.hpp"
namespace boost { namespace mpl {
template< typename C , typename F1 , typename F2 > struct apply_if { typedef BOOST_DEDUCED_TYPENAME eval_if<C,F1,F2>::type type; };
I tried a global replace of apply_if with eval_if; however, I got: <-------------------- intel-linux.compile.c++ ../../../../bin.v2/lje/libs/managed_ptr/test/intel-linux/debug/smart_ptr_test.o ../../../boost/managed_ptr/smart_ptr.hpp(204): error: class "boost::mpl::eval_if<boost::mpl::bool_<false>::type, boost::mpl::identity<boost::ref_counted<boost::mpl::_>>, boost::detail::get_policy<boost::mpl::list<boost::managed_ptr::refcycle_counted_curry_prox_visitor<boost::managed_ptr::refcycle_prox_visitor_abs::this_type>::owner_refptr<boost::mpl::_>, boost::empty_policy, boost::empty_policy, boost::empty_policy, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na>, boost::ownership_policy_tag, boost::ref_counted<boost::mpl::_>>::iter_>" has no member "type" >::type type; ^ detected during: instantiation of class "boost::detail::get_policy<Sequence, Category, Default> [with Sequence=boost::mpl::list<boost::managed_ptr::refcycle_counted_curry_prox_visitor<boost::managed_ptr::refcycle_prox_visitor_abs::this_type>::owner_refptr<boost::mpl::_>, boost::empty_policy, boost::empty_policy, boost::empty_policy, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na>, Category=boost::ownership_policy_tag, Default=boost::ref_counted<boost::mpl::_>]" at line 225
----------------
I've searched mail archives for apply_if and eval_if and looked at: http://www.boost.org/libs/mpl as directed by comments in eval_if.hpp; however, none were any help except the one I'm replying to. How does one replace apply_if with eval_if to avoid the above error message. TIA. Regards, Larry

On 10/12/2004 10:23 PM, Larry Evans wrote: [snip]
How does one replace apply_if with eval_if to avoid the above error message.
FWIW, the como -E compile command produces this output: <----------------- namespace boost { namespace mpl { template< typename C = na , typename F1 = na , typename F2 = na > struct eval_if : if_<C,F1,F2>::type { }; ...
-----------------

On 10/13/2004 08:40 AM, Larry Evans wrote:
On 10/12/2004 10:23 PM, Larry Evans wrote: [snip] FWIW, the como -E compile command produces this output:
<----------------- namespace boost { namespace mpl {
template< typename C = na , typename F1 = na , typename F2 = na > struct eval_if
: if_<C,F1,F2>::type {
};
...
-----------------
That's probably not the problem, because with this input: <------------- #include <boost/mpl/eval_if.hpp> struct A{}; struct B{}; struct C{}; typedef boost::mpl::eval_if<A,B,C>::type X; X x;
-------------
compilation succeeds.

On 10/13/2004 01:47 PM, Larry Evans wrote:
That's probably not the problem, because with this input:
<------------- #include <boost/mpl/eval_if.hpp> struct A{}; struct B{}; struct C{}; typedef boost::mpl::eval_if<A,B,C>::type X; X x;
-------------
compilation succeeds.
OOPS. Forgot to rm the -E flag. The following: <---------------- #include <boost/mpl/eval_if.hpp> struct C { static bool const value=true; }; struct f1 {}; struct f2 {}; namespace boost{namespace mpl{ typedef eval_if<C,f1,f2>::type X; X x; }}
---------------- gets error: <---------------- test.cpp(12): error: class "boost::mpl::eval_if<C, f1, f2>" has no member "type" typedef eval_if<C,f1,f2>::type X; ^ ----------------

Larry Evans writes:
I tried a global replace of apply_if with eval_if; however, I got: <--------------------
intel-linux.compile.c++ ../../../../bin.v2/lje/libs/managed_ptr/test/intel-linux/debug/smart_ptr_test.o ../../../boost/managed_ptr/smart_ptr.hpp(204): error: class "boost::mpl::eval_if<boost::mpl::bool_<false>::type, boost::mpl::identity<boost::ref_counted<boost::mpl::_>>,
boost::detail::get_policy<boost::mpl::list<boost::managed_ptr::refcycle_counted_curry_prox_visitor<boost::managed_ptr::refcycle_prox _visitor_abs::this_type>::owner_refptr<boost::mpl::_>,
boost::empty_policy, boost::empty_policy, boost::empty_policy, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na, boost::mpl::na>, boost::ownership_policy_tag, boost::ref_counted<boost::mpl::_>>::iter_>" has no member "type" >::type type; ^
Larry, this is not related to "apply_if" renaming, but rather to changes in the MPL's iterator protocol -- http://www.mywikinet.com/mpl/mpl_1_32_changelog/iterator-protocol.html. In particular, every place where you're dereferencing MPL iterators via '::type' needs to be re-written using 'mpl::deref' metafunction, as per cited document. HTH, -- Aleksey Gurtovoy MetaCommunications Engineering

On 10/13/2004 01:56 PM, Aleksey Gurtovoy wrote: [snip]
Larry, this is not related to "apply_if" renaming, but rather to changes in the MPL's iterator protocol -- http://www.mywikinet.com/mpl/mpl_1_32_changelog/iterator-protocol.html.
In particular, every place where you're dereferencing MPL iterators via '::type' needs to be re-written using 'mpl::deref' metafunction, as per cited document.
HTH, --
Thanks Aleksey. However, following the first row in that table: Before Now ------ --- i::type deref<i>::type I changed the toy example to: <------------------ #include <boost/mpl/eval_if.hpp> #include <boost/mpl/deref.hpp> struct C { static bool const value=true; }; struct f1 {}; struct f2 {}; namespace boost{namespace mpl{ typedef deref<eval_if<C,f1,f2> >::type X; X x; }}
------------------ and got this error: <------------------ /home/evansl/prog_dev/boost-snapshot/boost-04-10-04-0600/boost/mpl/deref.hpp(30): error: class "boost::mpl::eval_if<C, f1, f2>" has no member "type" typedef typename Iterator::type type; ^ detected during instantiation of class "boost::mpl::deref<Iterator> [with Iterator=boost::mpl::eval_if<C, f1, f2>]" at line 13 of "test.cpp" ------------------ Please let me know what else I should do.
TIA. Regards, Larry

On 10/13/2004 02:15 PM, Larry Evans wrote: [snip]
I changed the toy example to:
<------------------ #include <boost/mpl/eval_if.hpp> #include <boost/mpl/deref.hpp> struct C { static bool const value=true; }; struct f1 {}; struct f2 {}; namespace boost{namespace mpl{
typedef deref<eval_if<C,f1,f2> >::type X; X x;
}}
------------------ and got this error:
I apologize. Both f1 and f2 need a typedef for type.

Larry Evans writes:
On 10/13/2004 01:56 PM, Aleksey Gurtovoy wrote: [snip]
Larry, this is not related to "apply_if" renaming, but rather to changes in the MPL's iterator protocol -- http://www.mywikinet.com/mpl/mpl_1_32_changelog/iterator-protocol.html. In particular, every place where you're dereferencing MPL iterators via '::type' needs to be re-written using 'mpl::deref' metafunction, as per cited document. HTH, --
Thanks Aleksey. However, following the first row in that table:
Before Now ------ --- i::type deref<i>::type
I changed the toy example to:
<------------------ #include <boost/mpl/eval_if.hpp> #include <boost/mpl/deref.hpp> struct C { static bool const value=true; }; struct f1 {}; struct f2 {}; namespace boost{namespace mpl{
typedef deref<eval_if<C,f1,f2> >::type X; X x;
Oh, this is not at all what I meant. 'eval_if<C,f1,f2>' is not an iterator.
}}
------------------ and got this error: <------------------ /home/evansl/prog_dev/boost-snapshot/boost-04-10-04-0600/boost/mpl/deref.hpp(30): error: class "boost::mpl::eval_if<C, f1, f2>" has no member "type" typedef typename Iterator::type type; ^ detected during instantiation of class "boost::mpl::deref<Iterator> [with Iterator=boost::mpl::eval_if<C, f1, f2>]" at line 13 of "test.cpp" ------------------ Please let me know what else I should do.
If you provide me with the [location of the] code you're trying to compile, I'll try to take a quick look at it. -- Aleksey Gurtovoy MetaCommunications Engineering

On 10/13/2004 07:26 PM, Aleksey Gurtovoy wrote: [snip]
If you provide me with the [location of the] code you're trying to compile, I'll try to take a quick look at it.
It's here: http://cvs.sourceforge.net/viewcvs.py/boost-sandbox/boost-sandbox/boost/managed_ptr/smart_ptr.hpp?rev=1.2&view=auto specifically: template <class Sequence, class Category, class Default> struct get_policy { typedef typename mpl::find_if< Sequence, is_same<get_category<_>, Category> >::type iter_; typedef typename mpl::end<Sequence>::type last_; typedef typename mpl::apply_if< typename is_same<iter_, last_>::type, mpl::identity<Default>, iter_ >::type type; }; I replaced the apply_if with eval_if and got the previously mentioned errors. Thanks for the help.

Larry Evans writes:
It's here:
specifically:
template <class Sequence, class Category, class Default> struct get_policy { typedef typename mpl::find_if< Sequence, is_same<get_category<_>, Category> >::type iter_; typedef typename mpl::end<Sequence>::type last_; typedef typename mpl::apply_if< typename is_same<iter_, last_>::type, mpl::identity<Default>, iter_ ^^^^^ mpl::deref<iter_>
>::type type; };
I replaced the apply_if with eval_if and got the previously mentioned errors.
The above should help. -- Aleksey Gurtovoy MetaCommunications Engineering
participants (6)
-
Aleksey Gurtovoy
-
David Abrahams
-
Joel
-
Jonathan Turkanis
-
Larry Evans
-
Robert Ramey