2014-11-19 16:43 GMT+01:00 Peter Dimov
Andrzej Krzemienski wrote:
2014-11-19 16:28 GMT+01:00 Krzysztof Czainski <1czajnik@gmail.com>:
And then, why wouldn't a straightforward solution work:
struct none_t {};
none_t const none = {}
I think it validates ODR, or doesn't it?
It does violate ODR at places (without any ill effects AFAIK). Bind's placeholders have the same problem.
Hmm, looks like an option (although technically this is an UB)
One option is to use
struct none_rt {};
typedef none_rt (*none_t)();
inline none_rt none() { return none_rt(); }
Not an option. According to GCC, the following compiles: void d(none_t) {} int main() { d(0); } And this is exactly what I try to avoid.
Another is to declare none as constexpr:
struct none_t {};
constexpr none_t none = {};
Not an option: requires C++11