This question already has an answer here:
Given the following:
#define createProp(label, m_tt) \
template<> struct prop<Props::##label> { using type = m_ty; };
enum class Props;
template<Props Type>
struct prop;
enum class Props { Fullscreen, Borderless, };
createProp(Fullscreen, bool)
struct PropHolder {
template<Props Type>
void setProperty(prop<Type>::type value) { } //Error Here
template<Props Type>
prop<Type>::type getProperty() { } //Error here
};
When trying to compile it, the compiler will fail to recognize type in prop struct. Error list gives the warning 'prop<Type>::type': dependent name is not a type followed by the error syntax error: identifier 'type' (in lines marked by comments above).
Why isn't it a type? I've tried using both using type = m_ty and typedef m_ty type. Both of them are throwing the same error
Is the syntax error caused by the warning? Or did I misspell something? What should I do to preserve all setProperty, getProperty and createProp(...) as they are?
Also, how should I do so the macro also defines constexpr Props Prop_Fullscreen = Props::Fullscreen? Would constexpr Props Prop_##label = Props::##label work? I'm not sure how token-pasting works.
Aucun commentaire:
Enregistrer un commentaire