Reputation: 24705
How I'm suppose to implement a macro that would do something like this:
//pseudocode
#define CHOOSE(X) if(X) expand to "" and if !X expand to return nullptr;
Edit
template<class SomePolicy>
struct M
{
template<class Policy = SomePolicy>
typename std::enable_if<IsThrow<Policy>::value,void>::type fnc()
{
}
template<class Policy = SomePolicy>
typename std::enable_if<!IsThrow<Policy>::value,std::nullptr_t>::type fnc()
{
return nullptr;
}
};
@All_WHO_TRIED_TO_HELP_ME Hey Guys I want to thank you very much for your priceless help. It couldn't be done without you. Thanks to all of you. Thank you.
Upvotes: 0
Views: 228
Reputation: 27023
Answer to edit section.
Use the fact that expression return g();
is valid even if g
return void
.
template <class T> T GetDefault() { return T(); }
template <> void GetDefault<void>() { } // special case for void
and use
return GetDefault<void>();
or
return GetDefault<std::nullptr_t>();
Upvotes: 2
Reputation: 54178
Don't use a macro, use an inline function. I am not sure what it would return in this case but that's an issue either way.
Upvotes: 1
Reputation: 2902
You're not supposed to implement macros if you have C++ !
What do you want to do exactly ???
Upvotes: 1