LogCabin
Core/CompatHash.h
Go to the documentation of this file.
00001 /* Copyright (c) 2015 Diego Ongaro
00002  *
00003  * Permission to use, copy, modify, and distribute this software for any
00004  * purpose with or without fee is hereby granted, provided that the above
00005  * copyright notice and this permission notice appear in all copies.
00006  *
00007  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
00008  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00009  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR
00010  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00011  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00012  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00013  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00014  */
00015 
00016 #include <memory>
00017 
00018 #ifndef LOGCABIN_CORE_COMPATHASH_H
00019 #define LOGCABIN_CORE_COMPATHASH_H
00020 
00021 // missing std::hash<std::shared_ptr<T>> implementation on gcc 4.4 and 4.5
00022 // Clang has it but but has defines like gcc 4.2.
00023 #if __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !__clang__
00024 
00025 namespace std {
00026 
00027 template<typename T>
00028 struct hash<shared_ptr<T>>
00029 {
00030   size_t operator()(const shared_ptr<T>& s) const {
00031       return hash<T*>()(s.get());
00032   }
00033 };
00034 
00035 } // namespace std
00036 
00037 #endif // gcc < 4.6
00038 
00039 #endif /* LOGCABIN_CORE_COMPATHASH_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines