26 #ifndef LUNCHBOX_STDEXT_H 
   27 #define LUNCHBOX_STDEXT_H 
   29 #include <lunchbox/algorithm.h>  
   30 #include <lunchbox/compiler.h> 
   31 #include <lunchbox/uint128_t.h> 
   36 #ifdef LB_USE_STD_PARALLEL 
   37 #  include <parallel/algorithm> 
   41 #ifdef CXX_UNORDERED_MAP_SUPPORTED 
   42 #  define LB_STDEXT_STD 
   43 #  define LB_STDEXT_STD11 
   44 #elif defined __GNUC__ 
   45 #  if defined LB_GCC_4_3_OR_LATER && !defined __INTEL_COMPILER 
   46 #    define LB_STDEXT_TR1 
   47 #  elif defined __clang__ 
   48 #    define LB_STDEXT_TR1 
   50 #    define LB_STDEXT_EXT 
   52 #elif defined _MSC_VER 
   53 #  define LB_STDEXT_MSVC 
   55 #  define LB_STDEXT_TR1 
   56 #  define LB_STDEXT_TR1_BOOST 
   58 #  define LB_STDEXT_STD 
   62 #  ifdef LB_STDEXT_TR1_BOOST 
   63 #    include <boost/tr1/functional.hpp> 
   64 #    include <boost/tr1/unordered_map.hpp> 
   65 #    include <boost/tr1/unordered_set.hpp> 
   67 #    include <tr1/unordered_map> 
   68 #    include <tr1/unordered_set> 
   71 namespace stde = std::tr1;
 
   72 #  define LB_STDEXT_NAMESPACE_OPEN namespace std { namespace tr1 { 
   73 #  define LB_STDEXT_NAMESPACE_CLOSE }} 
   77 #  include <ext/hash_map> 
   78 #  include <ext/hash_set> 
   80 namespace stde = __gnu_cxx;
 
   81 #  define LB_STDEXT_NAMESPACE_OPEN namespace __gnu_cxx { 
   82 #  define LB_STDEXT_NAMESPACE_CLOSE } 
   89 namespace stde = stdext;
 
   90 #  define LB_STDEXT_NAMESPACE_OPEN namespace stdext { 
   91 #  define LB_STDEXT_NAMESPACE_CLOSE } 
   95 #  ifdef LB_STDEXT_STD11 
   96 #    include <unordered_map> 
   97 #    include <unordered_set> 
  103 namespace stde = std;
 
  104 #  define LB_STDEXT_NAMESPACE_OPEN namespace std { 
  105 #  define LB_STDEXT_NAMESPACE_CLOSE } 
  109 LB_STDEXT_NAMESPACE_OPEN
 
  112 #if defined LB_STDEXT_TR1 || defined LB_STDEXT_STD11 
  113 #  ifndef LB_HAVE_HASH_MAP 
  114 #    ifdef CXX_TEMPLATE_ALIAS_SUPPORTED 
  115 template< 
class K, 
class T, 
class H = hash< K >, 
class P = std::equal_to< K >,
 
  116           class A = std::allocator< std::pair< const K, T > > >
 
  117 using hash_map = unordered_map< K, T, H, P, A >;
 
  119 template< 
class K, 
class T, 
class H = hash< K >, 
class P = std::equal_to< K >,
 
  120           class A = std::allocator< std::pair< const K, T > > >
 
  121 class hash_map : 
public unordered_map< K, T, H, P, A > {};
 
  123 #  endif // LB_HAVE_HASH_MAP 
  124 #  ifndef LB_HAVE_HASH_SET 
  125 #    ifdef CXX_TEMPLATE_ALIAS_SUPPORTED 
  126 template< 
class T, 
class H = hash< T >,
 
  127           class P = std::equal_to< T >, 
class A = std::allocator< T > >
 
  128 using hash_set = unordered_set< T, H, P, A >;
 
  130 template< 
class T, 
class H = hash< T >,
 
  131           class P = std::equal_to< T >, 
class A = std::allocator< T > >
 
  132 class hash_set : 
public unordered_set< T, H, P, A > {};
 
  134 #  endif // LB_HAVE_HASH_SET 
  138 #  ifndef LB_HAVE_STRING_HASH 
  140 template<> 
struct hash< std::string >
 
  142     size_t operator()( 
const std::string& str )
 const 
  143         { 
return hash< const char* >()( str.c_str() ); }
 
  145 #  endif // LB_HAVE_STRING_HASH 
  147 #  if !defined __INTEL_COMPILER 
  148 #    ifndef LB_HAVE_LONG_HASH 
  150 template<> 
struct hash< uint64_t >
 
  152     size_t operator()( 
const uint64_t& val )
 const 
  156         return static_cast< size_t >( val );
 
  160 #  endif // !__INTEL_COMPILER 
  162 #  ifndef LB_HAVE_VOID_PTR_HASH 
  164 template<> 
struct hash< void* >
 
  166     template< 
typename P > 
size_t operator()( 
const P& key )
 const 
  167         { 
return reinterpret_cast<size_t>(key); }
 
  170 template<> 
struct hash< const void* >
 
  172     template< 
typename P > 
size_t operator()( 
const P& key )
 const 
  173         { 
return reinterpret_cast<size_t>(key); }
 
  175 #  endif // LB_HAVE_VOID_PTR_HASH 
  176 #endif // LB_STDEXT_EXT 
  178 #ifdef LB_STDEXT_MSVC 
  179 #  ifndef LB_HAVE_STRING_HASH 
  183 size_t hash_compare< std::string >::operator() ( 
const std::string& key )
 const 
  184     { 
return hash_value( key.c_str( )); }
 
  188 template<> 
inline size_t hash_compare< lunchbox::uint128_t >::operator()
 
  191     return static_cast< size_t >( key.high() ^ key.low() );
 
  195     { 
return static_cast< size_t >( key.
high() ^ key.
low() ); }
 
  199 template<> 
struct hash< lunchbox::uint128_t >
 
  202         { 
return key.
high() ^ key.
low(); }
 
  209 #ifndef LB_STDEXT_STD 
  211 #  ifdef LB_GCC_4_4_OR_LATER 
  212 using __gnu_parallel::sort;
 
  218 LB_STDEXT_NAMESPACE_CLOSE
 
  221 #endif // LUNCHBOX_STDEXT_H 
const uint64_t & high() const 
 
const uint64_t & low() const 
 
A base type for 128 bit unsigned integer values. 
 
void usort(C &c)
Uniquely sort and eliminate duplicates in a container.