Re: [Boost-users] [boost] Switch library review - summary of discussion so far
On Jan 12, 2008 8:25 AM, Mathias Gaunard
Stjepan Rajko wrote:
* Default default behavior
Alexander Nasonov has also indicated that a throwing default case can cause inefficiency, even when it is guaranteed not to be invoked.
Wouldn't an assert be more suited then? If default behaviour is unspecified and yet invoked, terminating sounds like a good thing to do.
An assert was considered as well - e.g., see: http://groups.google.com.by/group/boost-list/msg/0d73059086974920 This behavior is also analogous to the standard switch statement - if the default label is omitted, and none of the cases is matched, no termination occurs.
There has been a lengthy discussion on the underlying design of the library, what it should offer, and whether the name of the library is appropriate. There are two types of designs that have been put forward as being appropriate and/or necessary for a Boost.Switch library. On one hand, there is the submitted design (labeled "A" in recent postings), which takes the switch cases in an MPL sequence and a single function object containing implementations of all cases. Joel de Guzman has proposed another design (labeled "B"), in which the switch cases are specified separately and allow a different function to be used for each case.
It seems to me that B is convertible to A... There would be no need to duplicate the interface then.
Under the right details, yes: http://thread.gmane.org/gmane.comp.lib.boost.user/32628/focus=169957 Tobias offered formal transforms between the two: http://groups.google.com.by/group/boost-list/msg/1b1fa0084cd7baad
An utility which converts B to A would be quite useful though, even outside of boost.switch.
Thanks for your comments! Stjepan
participants (1)
-
Stjepan Rajko