Closed akrzemi1 closed 8 years ago
You don't need to include both headers, just include type_switchN-patterns-xtl.hpp it works also with regular polymorphism. XTL makes the subclassing in C++ to be a special case of its generalized subtyping relation. If it doesn't work with regular class hierarchies, please file bugs with concrete examples.
Thanks. It works!
But given that it works, does the information in the README.md (known-bugs-and-limitations) still make sense?
The most recent experimentation and the header you are prpobably looking for is type_switchN-patterns.hpp.
Is <mach7/type_switchN-patterns-xtl.hpp>
not superior by now? Or is the former faster?
You are right, type_switchN-patterns.hpp was an intermediary step on the way to Match statement with multiple subjects. The first one was doing just type switching on multiple arguments (type_switchN.hpp), then the second one expanded it to the declaration syntax that was supported in match.hpp but will also be made obsolete (type_switchN-decl.hpp) and then the type_switchN-patterns.hpp was the actual extension to support the normal patterns. type_switchN-pattern-xtl.hpp was an extension of it. During header reorg some of these headers didn't even make it to mach7 folder, because they were used in just a couple of tests.
The file name is not final yet, ultimately I'd like to have a single header but it might be two: the current match.hpp and this one. Match statements in match.hpp support other ADT encoding schemes, which are not easily generalizable to multiple arguments. The type_switchN-patterns-xtl.hpp or whatever it will be renamed to will be the main header as it has the widest functionality, but I'd probably have to keep match.hpp as well.
It seams it is currently impossible to declare two type-switch statements in one file, where one is "traditional" (vtable-based) and the other is xtl-based. I need to include two headers:
type_switchN-patterns.hpp
andtype_switchN-patterns-xtl.hpp
which contain conflicting definitions.(For the same reason, I guess I would be unable to do a switch on two arguments, where one argument is a polymorphic type, and the other is
boost::variant
.)I realize, there are plans for unification. But for the time being, would it be possible to provide a way for the two headers to coexist? Define symbols in different namespaces,
#undef
the macros?