On 27 September 2015 at 15:03, David Stone
Andrzej posted another thread about creating a new compact_optional class. The goal of this class is to make it easy to create a new optional type with a special sentinel value. This allows easy customization per instance of an optional value.
This post is about the opposite approach: making it easier to specialize optional to provide special behavior for all instances of a given optional type.
When I bring this up, people often compare it to the vector<bool> specialization, but this is a completely different issue.
No, it's the same issue. It'll have subtly different behavior. Generic programming counts on the behavior being the same. The only reason vector<bool> is bad is because of its spelling. Had it been a different name, most people would be happy. optional<T> controls the lifetime of T. If you have a sentinel instead, then the lifetime of the engaged T is exactly the same as the lifetime of optional<T>. If you want a type with different behavior, give it a different name. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404