ds_trait_imp.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00031 
00032 // Permission to use, copy, modify, sell, and distribute this software
00033 // is hereby granted without fee, provided that the above copyright
00034 // notice appears in all copies, and that both that copyright notice and
00035 // this permission notice appear in supporting documentation. None of
00036 // the above authors, nor IBM Haifa Research Laboratories, make any
00037 // representation about the suitability of this software for any
00038 // purpose. It is provided "as is" without express or implied warranty.
00039 
00045 #ifndef DS_TRAIT_IMP_HPP
00046 #define DS_TRAIT_IMP_HPP
00047 
00048 namespace detail
00049 {
00050 
00051   template<class Cntnr, class DS_Category>
00052   struct erase_can_throw_imp
00053   {
00054     enum
00055       {
00056     value =
00057     pb_assoc::detail::is_same_type<
00058     DS_Category,
00059     ov_tree_ds_tag>::value
00060       };
00061   };
00062 
00063   template<class Cntnr>
00064   struct erase_can_throw_imp<
00065     Cntnr,
00066     compound_ds_tag>
00067   {
00068     enum
00069       {
00070     value = Cntnr::erase_can_throw
00071       };
00072   };
00073 
00074   template<class Cntnr, class DS_Category>
00075   struct erase_iterators_imp
00076   {
00077     enum
00078       {
00079     value =
00080     pb_assoc::detail::is_same_type<
00081     DS_Category,
00082     rb_tree_ds_tag>::value ||
00083     pb_assoc::detail::is_same_type<
00084     DS_Category,
00085     splay_tree_ds_tag>::value
00086       };
00087   };
00088 
00089   template<class Cntnr>
00090   struct erase_iterators_imp<
00091     Cntnr,
00092     compound_ds_tag>
00093   {
00094     enum
00095       {
00096     value = Cntnr::erase_iterators
00097       };
00098   };
00099 
00100   template<class Cntnr, class DS_Category>
00101   struct order_preserving_imp
00102   {
00103     enum
00104       {
00105     value =
00106     pb_assoc::detail::is_same_type<
00107     DS_Category,
00108     rb_tree_ds_tag>::value ||
00109     pb_assoc::detail::is_same_type<
00110     DS_Category,
00111     splay_tree_ds_tag>::value ||
00112     pb_assoc::detail::is_same_type<
00113     DS_Category,
00114     ov_tree_ds_tag>::value
00115       };
00116   };
00117 
00118   template<class Cntnr>
00119   struct order_preserving_imp<
00120     Cntnr,
00121     compound_ds_tag>
00122   {
00123     enum
00124       {
00125     value = Cntnr::order_preserving
00126       };
00127   };
00128 
00129   template<class Cntnr, class DS_Category>
00130   struct invalidation_guarantee_imp
00131   {
00132   private:
00133     enum
00134       {
00135     node_based =
00136     pb_assoc::detail::is_same_type<
00137     DS_Category,
00138     cc_hash_ds_tag>::value ||
00139     pb_assoc::detail::is_same_type<
00140     DS_Category,
00141     rb_tree_ds_tag>::value ||
00142     pb_assoc::detail::is_same_type<
00143     DS_Category,
00144     splay_tree_ds_tag>::value ||
00145     pb_assoc::detail::is_same_type<
00146     DS_Category,
00147     lu_ds_tag>::value
00148       };
00149 
00150     enum
00151       {
00152     vector_organized =
00153     pb_assoc::detail::is_same_type<
00154     DS_Category,
00155     cc_hash_ds_tag>::value
00156       };
00157 
00158   public:
00159     typedef
00160     typename cond_type<
00161       node_based,
00162       typename cond_type<
00163       vector_organized,
00164       find_invalidation_guarantee,
00165       range_invalidation_guarantee>::type,
00166       basic_invalidation_guarantee>::type
00167     type;
00168   };
00169 
00170   template<class Cntnr>
00171   struct invalidation_guarantee_imp<
00172     Cntnr,
00173     compound_ds_tag>
00174   {
00175     typedef typename Cntnr::invalidation_guarantee type;
00176   };
00177 
00178   template<class Cntnr, class DS_Category>
00179   struct reverse_iteration_imp
00180   {
00181     enum
00182       {
00183     value =
00184     is_same_type<
00185     DS_Category,
00186     rb_tree_ds_tag>::value ||
00187     is_same_type<
00188     DS_Category,
00189     splay_tree_ds_tag>::value
00190       };
00191   };
00192 
00193   template<class Cntnr>
00194   struct reverse_iteration_imp<
00195     Cntnr,
00196     compound_ds_tag>
00197   {
00198     enum
00199       {
00200     value = Cntnr::reverse_iteration
00201       };
00202   };
00203 
00204   template<class Cntnr, class DS_Category>
00205   struct split_join_imp
00206   {
00207     enum
00208       {
00209     value =
00210     is_same_type<
00211     DS_Category,
00212     rb_tree_ds_tag>::value ||
00213     is_same_type<
00214     DS_Category,
00215     splay_tree_ds_tag>::value ||
00216     is_same_type<
00217     DS_Category,
00218     ov_tree_ds_tag>::value
00219       };
00220   };
00221 
00222   template<class Cntnr>
00223   struct split_join_imp<
00224     Cntnr,
00225     compound_ds_tag>
00226   {
00227     enum
00228       {
00229     value = false
00230       };
00231   };
00232 
00233   template<class Cntnr>
00234   struct basic_data_structure_traits
00235   {
00236 
00237   private:
00238     typedef Cntnr cntnr;
00239 
00240     typedef typename Cntnr::ds_category ds_category;
00241 
00242   public:
00243     enum
00244       {
00245     erase_can_throw =
00246     pb_assoc::detail::erase_can_throw_imp<
00247     cntnr,
00248     ds_category>::value
00249       };
00250 
00251     enum
00252       {
00253     order_preserving =
00254     pb_assoc::detail::order_preserving_imp<
00255     cntnr,
00256     ds_category>::value
00257       };
00258 
00259     enum
00260       {
00261     erase_iterators =
00262     pb_assoc::detail::erase_iterators_imp<
00263     Cntnr,
00264     ds_category>::value
00265       };
00266 
00267     typedef
00268     typename pb_assoc::detail::invalidation_guarantee_imp<
00269       cntnr,
00270       ds_category>::type
00271     invalidation_guarantee;
00272 
00273     enum
00274       {
00275     reverse_iteration =
00276     pb_assoc::detail::reverse_iteration_imp<
00277     cntnr,
00278     ds_category>::value
00279       };
00280 
00281     enum
00282       {
00283     split_join =
00284     pb_assoc::detail::split_join_imp<
00285     cntnr,
00286     ds_category>::value
00287       };
00288   };
00289 
00290   template<class Cntnr, class DS_Category>
00291   struct data_structure_traits : public basic_data_structure_traits<
00292     Cntnr>
00293   { };
00294 
00295   template<class Cntnr>
00296   struct data_structure_traits<
00297     Cntnr,
00298     rb_tree_ds_tag> : public basic_data_structure_traits<
00299     Cntnr>
00300   {
00301   public:
00302     enum
00303       {
00304     split_join_can_throw = false
00305       };
00306   };
00307 
00308   template<class Cntnr>
00309   struct data_structure_traits<
00310     Cntnr,
00311     splay_tree_ds_tag> : public basic_data_structure_traits<
00312     Cntnr>
00313   {
00314   public:
00315     enum
00316       {
00317     split_join_can_throw = false
00318       };
00319   };
00320 
00321   template<class Cntnr>
00322   struct data_structure_traits<
00323     Cntnr,
00324     ov_tree_ds_tag> : public basic_data_structure_traits<
00325     Cntnr>
00326   {
00327   public:
00328     enum
00329       {
00330     split_join_can_throw = true
00331       };
00332   };
00333 
00334 } // namespace detail
00335 
00336 #endif // #ifndef DS_TRAIT_IMP_HPP

Generated on Tue Feb 2 16:55:55 2010 for GNU C++ STL by  doxygen 1.4.7