Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typename reflection for map<K,V,std::less<>> #247

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 45 additions & 35 deletions include/fc/reflect/typename.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ namespace fc {
template<> struct get_typename<value> { static const char* name() { return "value"; } };
template<> struct get_typename<std::string> { static const char* name() { return "string"; } };
template<> struct get_typename<fc::exception> { static const char* name() { return "fc::exception"; } };
template<> struct get_typename<std::vector<char>> { static const char* name() { return "std::vector<char>"; } };
template<typename T> struct get_typename<std::vector<T>>
{
static const char* name() {
static std::string n = std::string("std::vector<") + get_typename<T>::name() + ">";
return n.c_str();
}
template<> struct get_typename<std::vector<char>> { static const char* name() { return "std::vector<char>"; } };
template<typename T> struct get_typename<std::vector<T>>
{
static const char* name() {
static std::string n = std::string("std::vector<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<flat_set<T>>
{
Expand All @@ -54,41 +54,50 @@ namespace fc {
};
template<typename... Ts>
struct get_typename<flat_set<static_variant<Ts...>, typename static_variant<Ts...>::type_lt>>
{
static const char* name() {
{
static const char* name() {
using TN = get_typename<static_variant<Ts...>>;
static std::string n = std::string("flat_set<") + TN::name() + ", " + TN::name() + "::type_lt>";
return n.c_str();
}
static std::string n = std::string("flat_set<") + TN::name() + "," + TN::name() + "::type_lt>";
return n.c_str();
}
};
template<typename T, typename U> struct get_typename<flat_map<T, U>>
{
static const char* name() {
static std::string n = std::string("flat_map<") + get_typename<T>::name() + ", " + get_typename<U>::name() + ">";
static std::string n = std::string("flat_map<") + get_typename<T>::name() + "," + get_typename<U>::name()
+ ">";
return n.c_str();
}
};
template<typename T> struct get_typename< std::deque<T> >
{
static const char* name()
{
static std::string n = std::string("std::deque<") + get_typename<T>::name() + ">";
return n.c_str();
static std::string n = std::string("std::deque<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<optional<T>>
{
static const char* name() {
static std::string n = std::string("optional<") + get_typename<T>::name() + ">";
return n.c_str();
}
};
template<typename T> struct get_typename<optional<T>>
{
static const char* name() {
static std::string n = std::string("optional<") + get_typename<T>::name() + ">";
return n.c_str();
}
template<typename K,typename V> struct get_typename<std::map<K,V>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()+">";
return n.c_str();
}
};
template<typename K,typename V> struct get_typename<std::map<K,V>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()+">";
return n.c_str();
}
template<typename K,typename V> struct get_typename<std::map<K,V,std::less<>>>
{
static const char* name() {
static std::string n = std::string("std::map<") + get_typename<K>::name() + ","+get_typename<V>::name()
+ ",std::less<>>";
return n.c_str();
}
};
template<typename E> struct get_typename< std::set<E> >
{
Expand All @@ -102,19 +111,20 @@ namespace fc {
{
static const char* name()
{
static std::string n = std::string("std::pair<") + get_typename<A>::name() + "," + get_typename<B>::name() + ">";
static std::string n = std::string("std::pair<") + get_typename<A>::name() + "," + get_typename<B>::name()
+ ">";
return n.c_str();
}
};
template<typename T,size_t N> struct get_typename< std::array<T,N> >
{
static const char* name()
{
};
template<typename T,size_t N> struct get_typename< std::array<T,N> >
{
static const char* name()
{
static std::string _name = std::string("std::array<") + std::string(fc::get_typename<T>::name())
+ "," + fc::to_string(N) + ">";
return _name.c_str();
}
};
}
};
template<typename T> struct get_typename< const T* >
{
static const char* name()
Expand Down