Unverified Commit b9af3723 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Allow type info to be used as a key. (#3822)

parent 50329a59
...@@ -17,8 +17,11 @@ ...@@ -17,8 +17,11 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string>
#include <utility> #include <utility>
#include "ngraph/ngraph_visibility.hpp"
namespace ngraph namespace ngraph
{ {
/// Supports three functions, is_type<Type>, as_type<Type>, and as_type_ptr<Type> for type-safe /// Supports three functions, is_type<Type>, as_type<Type>, and as_type_ptr<Type> for type-safe
...@@ -28,12 +31,19 @@ namespace ngraph ...@@ -28,12 +31,19 @@ namespace ngraph
/// Type information for a type system without inheritance; instances have exactly one type not /// Type information for a type system without inheritance; instances have exactly one type not
/// related to any other type. /// related to any other type.
NGRAPH_API
struct DiscreteTypeInfo struct DiscreteTypeInfo
{ {
const char* name; const char* name;
uint64_t version; uint64_t version;
bool is_castable(const DiscreteTypeInfo& target_type) const { return this == &target_type; } bool is_castable(const DiscreteTypeInfo& target_type) const { return this == &target_type; }
// For use as a key
bool operator<(const DiscreteTypeInfo& b) const
{
return version < b.version ||
(version == b.version && std::string(name) < std::string(b.name));
}
}; };
/// \brief Tests if value is a pointer/shared_ptr that can be statically cast to a /// \brief Tests if value is a pointer/shared_ptr that can be statically cast to a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment