|
Boost Users : |
From: Slawomir Lisznianski (public_at_[hidden])
Date: 2006-01-08 12:10:45
Hello,
I'm trying to find a solution to the following problem. Given types A, B
and C such that C is derived from B and B is derived from A, and a
sequence S1 which stores A, B and C (in arbitrary order):
1) transform S1 so resulting sequence S2 would have elements sorted
according to their relative position within their inheritance hierarchy
(say, most derived first).
2) when one introduces another type, D, which doesn't inherit from any
of A, B or C, after sorting S1, it would end up at the end of S2.
3) the solution needs to be unintrusive for the "input" types, that is,
it ought to work for existing types.
Example
-------
Input:
S1 = { A, C, D, B };
Expected result, after sorting:
S2 = { C, B, A, D };
Purpose
-------
By finding a way to sort S1 according to predicates listed above, I hope
to come up with a generic exception-handling mechanism (used in RPC-like
library), example:
typedef vector<E0, E1, .. ,En> sorted_exception_decl;
try
{
func();
}
catch(at<sorted_exception_decl, int_<0> >::value const & E0)
{ .. }
catch(at<sorted_exception_decl, int_<1> >::value const & E1)
{ .. }
catch(at<sorted_exception_decl, int_<n> >::value const & En)
{ .. }
Your thoughts on how sane this idea is are greatly appreciated.
-- Slawomir Lisznianski Paramay Group, LLC "Programs for Research Machinery"
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net