include/corelib/ncbistl.hpp

Go to the documentation of this file.
00001 #ifndef CORELIB___NCBISTL__HPP
00002 #define CORELIB___NCBISTL__HPP
00003 
00004 /*  $Id: ncbistl.hpp 166469 2009-07-22 22:01:07Z ucko $
00005  * ===========================================================================
00006  *
00007  *                            PUBLIC DOMAIN NOTICE
00008  *               National Center for Biotechnology Information
00009  *
00010  *  This software/database is a "United States Government Work" under the
00011  *  terms of the United States Copyright Act.  It was written as part of
00012  *  the author's official duties as a United States Government employee and
00013  *  thus cannot be copyrighted.  This software/database is freely available
00014  *  to the public for use. The National Library of Medicine and the U.S.
00015  *  Government have not placed any restriction on its use or reproduction.
00016  *
00017  *  Although all reasonable efforts have been taken to ensure the accuracy
00018  *  and reliability of the software and data, the NLM and the U.S.
00019  *  Government do not and cannot warrant the performance or results that
00020  *  may be obtained by using this software or data. The NLM and the U.S.
00021  *  Government disclaim all warranties, express or implied, including
00022  *  warranties of performance, merchantability or fitness for any particular
00023  *  purpose.
00024  *
00025  *  Please cite the author in any work or product based on this material.
00026  *
00027  * ===========================================================================
00028  *
00029  * Author:  Denis Vakatov
00030  *
00031  *
00032  */
00033 
00034 /// @file ncbistl.hpp
00035 /// The NCBI C++/STL use hints.
00036 
00037 
00038 #include <common/ncbi_export.h>
00039 
00040 
00041 // Get rid of some warnings in MSVC++ 6.00
00042 #if (_MSC_VER >= 1200)
00043 // too long identificator name in the debug info;  truncated
00044 #  pragma warning(disable: 4786)
00045 // too long decorated name;  truncated
00046 #  pragma warning(disable: 4503)
00047 // default copy constructor cannot be generated
00048 #  pragma warning(disable: 4511)
00049 // default assignment operator cannot be generated
00050 #  pragma warning(disable: 4512)
00051 // synonymous name used
00052 #  pragma warning(disable: 4097)
00053 // inherits ... via dominance
00054 #  pragma warning(disable: 4250)
00055 // 'this' : used in base member initializer list
00056 #  pragma warning(disable: 4355)
00057 // identifier was truncated to '255' characters in the browser information
00058 #  pragma warning(disable: 4786)
00059 #endif /* _MSC_VER >= 1200 */
00060 
00061 
00062 /** @addtogroup STL
00063  *
00064  * @{
00065  */
00066 
00067 
00068 /// Define a new scope.
00069 #define BEGIN_SCOPE(ns) namespace ns {
00070 
00071 /// End the previously defined scope.
00072 #define END_SCOPE(ns) }
00073 
00074 /// Use the specified namespace.
00075 #define USING_SCOPE(ns) using namespace ns
00076 
00077 // Using STD and NCBI namespaces
00078 
00079 /// Define the std namespace.
00080 #define NCBI_NS_STD  std
00081 
00082 /// Use the std namespace.
00083 #define NCBI_USING_NAMESPACE_STD using namespace NCBI_NS_STD
00084 
00085 /// Define the name for the NCBI namespace.
00086 #define NCBI_NS_NCBI ncbi
00087 
00088 /// Place it for adding new funtionality to STD scope
00089 #define BEGIN_STD_SCOPE BEGIN_SCOPE(NCBI_NS_STD)
00090 
00091 /// End previously defined STD scope.
00092 #define END_STD_SCOPE   END_SCOPE(NCBI_NS_STD)
00093 
00094 /// Define ncbi namespace.
00095 ///
00096 /// Place at beginning of file for NCBI related code.
00097 #define BEGIN_NCBI_SCOPE BEGIN_SCOPE(NCBI_NS_NCBI)
00098 
00099 /// End previously defined NCBI scope.
00100 #define END_NCBI_SCOPE   END_SCOPE(NCBI_NS_NCBI)
00101 
00102 /// For using NCBI namespace code.
00103 #define USING_NCBI_SCOPE USING_SCOPE(NCBI_NS_NCBI)
00104 
00105 
00106 /// Magic spell ;-) needed for some weird compilers... very empiric.
00107 namespace NCBI_NS_STD  { /* the fake one */ }
00108 
00109 /// Magic spell ;-) needed for some weird compilers... very empiric.
00110 namespace NCBI_NS_NCBI { /* the fake one, +"std" */ NCBI_USING_NAMESPACE_STD; }
00111 
00112 /// Magic spell ;-) needed for some weird compilers... very empiric.
00113 namespace NCBI_NS_NCBI { /* the fake one */ }
00114 
00115 
00116 #if !defined(NCBI_NAME2)
00117 /// Name concatenation macro with two names.
00118 /// NB: If this names are macros themselves expanding will not take place.
00119 #  define NCBI_NAME2(Name1, Name2) Name1##Name2
00120 #endif
00121 #if !defined(NCBI_NAME3)
00122 /// Name concatenation macro with three names.
00123 /// NB: If this names are macros themselves expanding will not take place.
00124 #  define NCBI_NAME3(Name1, Name2, Name3) Name1##Name2##Name3
00125 #endif
00126 #if !defined(NCBI_EAT_SEMICOLON)
00127 #  define NCBI_EAT_SEMICOLON(UniqueName) \
00128 typedef int NCBI_NAME2(T_EAT_SEMICOLON_,UniqueName)
00129 #endif
00130 
00131 /// Convert some value to string even if this value is macro itself
00132 #define NCBI_AS_STRING(value)   NCBI_AS_STRING2(value)
00133 #define NCBI_AS_STRING2(value)   #value
00134 
00135 
00136 #if defined(NCBI_COMPILER_MSVC) && _MSC_VER < 1400 && !defined(for)
00137 /// Fix nonstandard 'for' statement behaviour on MSVC 7.1.
00138 # define for if(0);else for
00139 #endif
00140 
00141 #ifdef NCBI_COMPILER_ICC
00142 /// ICC may fail to generate code preceded by "template<>".
00143 #define EMPTY_TEMPLATE
00144 #else
00145 #define EMPTY_TEMPLATE template<>
00146 #endif
00147 
00148 #ifdef NCBI_COMPILER_WORKSHOP
00149 # if NCBI_COMPILER_VERSION < 530
00150 /// Advance iterator to end and then break out of loop.
00151 ///
00152 /// Sun WorkShop < 5.3 fails to call destructors for objects created in
00153 /// for-loop initializers; this macro prevents trouble with iterators
00154 /// that contain CRefs by advancing them to the end, avoiding
00155 /// "deletion of referenced CObject" errors.
00156 #  define BREAK(it) while (it) { ++(it); }  break
00157 # else
00158 #  define BREAK(it) break
00159 # endif
00160 #else
00161 # define BREAK(it) break
00162 #endif
00163 
00164 #if defined(NCBI_COMPILER_GCC) || defined(NCBI_COMPILER_WORKSHOP)
00165 // This template is used by some stl algorithms (sort, reverse...)
00166 // We need to have our own implementation because some C++ Compiler vendors 
00167 // implemented it by using a temporary variable and an assignment operator 
00168 // instead of std::swap function.
00169 // GCC 3.4 note: because this compiler has a broken function template 
00170 // specialization this template function should be defined before 
00171 // including any stl include files.
00172 BEGIN_STD_SCOPE
00173 template<typename Iter>
00174 inline
00175 void iter_swap( Iter it1, Iter it2 )
00176 {
00177     swap( *it1, * it2 );
00178 }
00179 
00180 END_STD_SCOPE
00181 
00182 #endif
00183 
00184 /* @} */
00185 
00186 #endif /* NCBISTL__HPP */
00187 
00188 

Generated on Wed Dec 9 03:06:45 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:17:29 2009 by modify_doxy.py rev. 173732