1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
/*désolé, mais j'ai trop l'habitude de prendre des noms anglais */
template <typename T, bool Convertible>
struct Strignifier;
/* il y aura quelques spécialisations (pour std::string, notamment) à ajouter par la suite ;) */
template <typename T,
struct Strignifier<T, true>{
std::string std::string toString(T const & v) const{
return std::to_string(v);
}
};
template <typename Type, bool StringConvertible = std::is_arithmetic_v<Type> ||
std::is_same_v<std::string, Type> ||
std::is_same_v<std::wstring, Type>>
struct Field{
using strignifier_type = Stringifier<Type, StringConvertible>;
Field(std::string const & n):name{n}{
}
std::string const name;
Type value;
};
template <typename T>
inline bool sameName(Fied<T> const & f, std::string const & name){
return f.name == name;
}
template <typename T, typename U,
typename = std::enable_if<std::is_same_v <T, U>::type>
bool operator = (Field <T> const & f, U const & test){
return f.value == test;
} |
Partager