Re: [Boost-bugs] [Boost C++ Libraries] #799: mpl::if_

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #799: mpl::if_
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-09-05 08:22:20


#799: mpl::if_
-------------------------------+--------------------------------------------
  Reporter: nobody | Owner: nobody
      Type: Feature Requests | Status: reopened
 Milestone: | Component: None
   Version: None | Severity: Showstopper
Resolution: | Keywords:
-------------------------------+--------------------------------------------
Changes (by anonymous):

  * status: closed => reopened
  * resolution: invalid =>

Comment:

 Replying to [comment:1 dave]:
> I disagree; it's far too verbose, and thus less clear, when you consider
 the need for the `template` keyword, which you left out.

 Ok, lets compare:

 1 condition:
 {{{
 #!cpp
 // Boost
 typedef Mpl::if_<C, T, E>::type X;

 // cbear
 typedef Meta::if_<C, T, E>::type X;
 }}}

 5 conditions:
 {{{
 #!cpp
 // Boost
 template<class C1, class C2, class C3, class C4, class C5>
 struct X:
         Mpl::if_<C1, T1,
         typename Mpl::if_<C2, T2,
         typename Mpl::if_<C3, T3,
         typename Mpl::if_<C4, T4,
         typename Mpl::if_<C5, T5,
         E
>::type
>::type
>::type
>::type
>
 {
 };

 // cbear
 template<class C1, class C2, class C3, class C4, class C5>
 struct X:
         Meta::if_<C1, T1>::
         template else_if<C2, T2>::
         template else_if<C3, T3>::
         template else_if<C4, T4>::
         template else_if<C5, T5>::
         template else_<E>
 {
 };
 }}}

 enable if T is integer:
 {{{
 #!cpp
 // Boost
 template<class T>
 T foo(T t, typename boost::enable_if<boost::is_integral<T> >::type* dummy
 = 0);

 // cbear
 template<class T>
 T foo(T t, typename Meta::if_<boost::is_integral<T> >::type* dummy = 0);
 }}}

 enable if T is integer (returns T) or pointer (returns int):
 {{{
 #!cpp
 // Boost
 template<class T>
 typename Mpl::lazy_enable_if<
         Mpl::or_<boost::is_integral<T>, boost::is_pointer<T> >, // !!!
         Mpl::if_<boost::is_integral<T>, T, int> >::type
 foo(T t);

 // cbear
 template<class T>
 typename Meta::if_<boost::is_integral<T>, T>::
 template else_if<boost::is_pointer<T>, int>::type
 foo(T t);
 }}}

 I would agree with some other arguments. But not with 'it's far too
 verbose, and thus less clear'. That's false!

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/799#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:56 UTC