logo       

CVS: boost/boost/pending ct_if.hpp,1.6,1.7: msg#00754

Subject: CVS: boost/boost/pending ct_if.hpp,1.6,1.7
Update of /cvsroot/boost/boost/boost/pending
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19760

Modified Files:
        ct_if.hpp 
Log Message:
Replaced the implementation of ct_if with a facade implementation that
defers to Boost.MPL.


Index: ct_if.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/pending/ct_if.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ct_if.hpp   30 Jan 2005 15:47:46 -0000      1.6
+++ ct_if.hpp   13 Nov 2006 15:35:54 -0000      1.7
@@ -3,107 +3,39 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-// The ct_if implementation that avoids partial specialization is
-// based on the IF class by Ulrich W. Eisenecker and Krzysztof
-// Czarnecki.
+// This header replaces the implementation of ct_if that preceded the
+// introduction of Boost.MPL with a facade that defers to that reviewed and
+// accepted library.
+
+// Author: Ronald Garcia
+// Date: 20 October, 2006
+
 
 #ifndef BOOST_CT_IF_HPP
 #define BOOST_CT_IF_HPP
 
-#include <boost/config.hpp>
 
-/*
-  There is a bug in the Borland compiler with regards to using
-  integers to specialize templates. This made it hard to use ct_if in
-  the graph library. Changing from 'ct_if' to 'ct_if_t' fixed the
-  problem.
-*/
+// A stub implementation in terms of Boost.MPL
 
-#include <boost/type_traits/integral_constant.hpp> // true_type and false_type
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/and.hpp>
+// true_type and false_type are used by applications of ct_if
+#include <boost/type_traits/integral_constant.hpp> 
 
 namespace boost {
 
-  struct ct_if_error { };
-
   template <class A, class B>
-  struct ct_and { typedef false_type type; };
-  template <> struct ct_and<true_type,true_type> { typedef true_type type; };
-
-  template <class A> struct ct_not { typedef ct_if_error type; };
-  template <> struct ct_not<true_type> { typedef false_type type; };
-  template <> struct ct_not<false_type> { typedef true_type type; };
+  struct ct_and : boost::mpl::and_<A,B> {};
 
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+  template <class A>
+  struct ct_not : mpl::not_<A> {};
 
-// agurt, 15/sep/02: in certain cases Borland has problems with
-// choosing the right 'ct_if' specialization even though 'cond' 
-// _does_ equal '1'; the easiest way to fix it is to make first 
-// 'ct_if' non-type template parameter boolean.
-#if !defined(__BORLANDC__)
   template <bool cond, class A, class B>
-  struct ct_if { typedef ct_if_error type; };
-  template <class A, class B>
-  struct ct_if<true, A, B> { typedef A type; };
-  template <class A, class B>
-  struct ct_if<false, A, B> { typedef B type; };
-#else
-  template <bool cond, class A, class B>
-  struct ct_if { typedef A type; };
-  template <class A, class B>
-  struct ct_if<false, A, B> { typedef B type; };
-#endif
-
-  template <class cond, class A, class B>
-  struct ct_if_t { typedef ct_if_error type; };
-  template <class A, class B>
-  struct ct_if_t<true_type, A, B> { typedef A type; };
-  template <class A, class B>
-  struct ct_if_t<false_type, A, B> { typedef B type; };
-
-#else
-
-  namespace detail {
-
-    template <int condition, class A, class B> struct IF;
-    template <int condition> struct SlectSelector;
-    struct SelectFirstType;
-    struct SelectSecondType;
-    
-    struct SelectFirstType {
-      template<class A, class B>
-      struct Template {        typedef A type; };
-    };
-    
-    struct SelectSecondType {
-      template<class A, class B>
-      struct Template { typedef B type; };
-    };
-    
-    template<int condition>
-    struct SlectSelector {
-      typedef SelectFirstType type;
-    };
-    
-    template <>
-    struct SlectSelector<0> {
-      typedef SelectSecondType type;
-    };
+  struct ct_if : mpl::if_c<cond,A,B> {};
 
-  } // namespace detail
-    
-  template<int condition, class A, class B>
-  struct ct_if
-  {
-    typedef typename detail::SlectSelector<condition>::type Selector;
-    typedef typename Selector::template Template<A, B>::type type;
-  };
-  
   template <class cond, class A, class B>
-  struct ct_if_t { 
-    typedef typename ct_if<cond::value, A, B>::type type;
-  };
-
-#endif
+  struct ct_if_t : mpl::if_<cond,A,B> {};
 
 } // namespace boost
 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe