mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 04:56:39 +00:00 
			
		
		
		
	To fix msvc error:
components\detournavigator\objectid.hpp(14,13): error C2440: 'reinterpret_cast': cannot convert from 'const T' to 'size_t'
          with
          [
              T=unsigned long
          ]
		
	
			
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_OBJECTID_H
 | 
						|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_OBJECTID_H
 | 
						|
 | 
						|
#include <cstddef>
 | 
						|
#include <unordered_map>
 | 
						|
 | 
						|
namespace DetourNavigator
 | 
						|
{
 | 
						|
    class ObjectId
 | 
						|
    {
 | 
						|
    public:
 | 
						|
        template <class T>
 | 
						|
        explicit ObjectId(T* value) throw()
 | 
						|
            : mValue(reinterpret_cast<std::size_t>(value))
 | 
						|
        {
 | 
						|
        }
 | 
						|
 | 
						|
        std::size_t value() const throw()
 | 
						|
        {
 | 
						|
            return mValue;
 | 
						|
        }
 | 
						|
 | 
						|
        friend bool operator <(const ObjectId lhs, const ObjectId rhs) throw()
 | 
						|
        {
 | 
						|
            return lhs.mValue < rhs.mValue;
 | 
						|
        }
 | 
						|
 | 
						|
        friend bool operator ==(const ObjectId lhs, const ObjectId rhs) throw()
 | 
						|
        {
 | 
						|
            return lhs.mValue == rhs.mValue;
 | 
						|
        }
 | 
						|
 | 
						|
    private:
 | 
						|
        std::size_t mValue;
 | 
						|
    };
 | 
						|
}
 | 
						|
 | 
						|
namespace std
 | 
						|
{
 | 
						|
    template <>
 | 
						|
    struct hash<DetourNavigator::ObjectId>
 | 
						|
    {
 | 
						|
        std::size_t operator ()(const DetourNavigator::ObjectId value) const throw()
 | 
						|
        {
 | 
						|
            return value.value();
 | 
						|
        }
 | 
						|
    };
 | 
						|
}
 | 
						|
 | 
						|
#endif
 |