enable_if.hpp

Go to the documentation of this file.
00001 // Boost enable_if library
00002 
00003 // Copyright 2003 © The Trustees of Indiana University.
00004 
00005 // Use, modification, and distribution is subject to the Boost Software
00006 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00007 // http://www.boost.org/LICENSE_1_0.txt)
00008 
00009 //    Authors: Jaakko Järvi (jajarvi at osl.iu.edu)
00010 //             Jeremiah Willcock (jewillco at osl.iu.edu)
00011 //             Andrew Lumsdaine (lums at osl.iu.edu)
00012 
00013 
00014 #ifndef BOOST_UTILITY_ENABLE_IF_HPP
00015 #define BOOST_UTILITY_ENABLE_IF_HPP
00016 
00017 #include "sysc/packages/boost/config.hpp"
00018 
00019 // Even the definition of enable_if causes problems on some compilers,
00020 // so it's macroed out for all compilers that do not support SFINAE
00021 
00022 #ifndef BOOST_NO_SFINAE
00023 
00024 namespace boost
00025 {
00026  
00027   template <bool B, class T = void>
00028   struct enable_if_c {
00029     typedef T type;
00030   };
00031 
00032   template <class T>
00033   struct enable_if_c<false, T> {};
00034 
00035   template <class Cond, class T = void> 
00036   struct enable_if : public enable_if_c<Cond::value, T> {};
00037 
00038   template <bool B, class T>
00039   struct lazy_enable_if_c {
00040     typedef typename T::type type;
00041   };
00042 
00043   template <class T>
00044   struct lazy_enable_if_c<false, T> {};
00045 
00046   template <class Cond, class T> 
00047   struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
00048 
00049 
00050   template <bool B, class T = void>
00051   struct disable_if_c {
00052     typedef T type;
00053   };
00054 
00055   template <class T>
00056   struct disable_if_c<true, T> {};
00057 
00058   template <class Cond, class T = void> 
00059   struct disable_if : public disable_if_c<Cond::value, T> {};
00060 
00061   template <bool B, class T>
00062   struct lazy_disable_if_c {
00063     typedef typename T::type type;
00064   };
00065 
00066   template <class T>
00067   struct lazy_disable_if_c<true, T> {};
00068 
00069   template <class Cond, class T> 
00070   struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
00071 
00072 } // namespace boost
00073 
00074 #else
00075 
00076 namespace boost {
00077 
00078   namespace detail { typedef void enable_if_default_T; }
00079 
00080   template <typename T>
00081   struct enable_if_does_not_work_on_this_compiler;
00082 
00083   template <bool B, class T = detail::enable_if_default_T>
00084   struct enable_if_c : enable_if_does_not_work_on_this_compiler<T>
00085   { };
00086 
00087   template <bool B, class T = detail::enable_if_default_T> 
00088   struct disable_if_c : enable_if_does_not_work_on_this_compiler<T>
00089   { };
00090 
00091   template <bool B, class T = detail::enable_if_default_T> 
00092   struct lazy_enable_if_c : enable_if_does_not_work_on_this_compiler<T>
00093   { };
00094 
00095   template <bool B, class T = detail::enable_if_default_T> 
00096   struct lazy_disable_if_c : enable_if_does_not_work_on_this_compiler<T>
00097   { };
00098 
00099   template <class Cond, class T = detail::enable_if_default_T> 
00100   struct enable_if : enable_if_does_not_work_on_this_compiler<T>
00101   { };
00102 
00103   template <class Cond, class T = detail::enable_if_default_T> 
00104   struct disable_if : enable_if_does_not_work_on_this_compiler<T>
00105   { };
00106 
00107   template <class Cond, class T = detail::enable_if_default_T> 
00108   struct lazy_enable_if : enable_if_does_not_work_on_this_compiler<T>
00109   { };
00110 
00111   template <class Cond, class T = detail::enable_if_default_T> 
00112   struct lazy_disable_if : enable_if_does_not_work_on_this_compiler<T>
00113   { };
00114 
00115 } // namespace boost
00116 
00117 #endif // BOOST_NO_SFINAE
00118 
00119 #endif

Generated on Wed Jan 21 15:32:10 2009 for SystemC by  doxygen 1.5.5