Added libfmt support for Name.
This commit is contained in:
		
							parent
							
								
									c44350269a
								
							
						
					
					
						commit
						27b163f4db
					
				@ -6,6 +6,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <limits>
 | 
					#include <limits>
 | 
				
			||||||
#include <string_view>
 | 
					#include <string_view>
 | 
				
			||||||
 | 
					#if __has_include(<fmt/format.h>)
 | 
				
			||||||
 | 
					#   include <fmt/format.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace mijin
 | 
					namespace mijin
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -49,15 +52,24 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
} // namespace mijin
 | 
					} // namespace mijin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace std
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
template<>
 | 
					template<>
 | 
				
			||||||
struct hash<mijin::Name> : hash<std::size_t>
 | 
					struct std::hash<mijin::Name> : hash<std::size_t>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    std::size_t operator()(mijin::Name name) const noexcept {
 | 
					    std::size_t operator()(mijin::Name name) const noexcept {
 | 
				
			||||||
        return hash<std::size_t>::operator()(name.getID());
 | 
					        return hash<std::size_t>::operator()(name.getID());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
}
 | 
					
 | 
				
			||||||
 | 
					#if __has_include(<fmt/format.h>)
 | 
				
			||||||
 | 
					template<>
 | 
				
			||||||
 | 
					struct fmt::formatter<mijin::Name> : fmt::formatter<std::string_view>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    template<typename TContext>
 | 
				
			||||||
 | 
					    auto format(mijin::Name name, TContext& ctx) const -> decltype(ctx.out())
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return fmt::formatter<std::string_view>::format(name.stringView(), ctx);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					#endif // __has_include(<fmt/format.h>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // !defined(MIJIN_TYPES_NAME_HPP_INCLUDED)
 | 
					#endif // !defined(MIJIN_TYPES_NAME_HPP_INCLUDED)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user