On Tue, 14 Dec 2010 00:49:10 -0800
Jonathan M Davis <[email protected]> wrote:
> It could definitely serve a purpose if _all_ of the possible template
> specializations fail. Presumably, you intend _one_ of them to work. But that
> _does_ mean that you get error messages for a number of different template
> specializations, and you have to sort through them. It _can_ take a fair bit
> of
> effort to figure out why a particular template constraint is failing, and it
> would
> definitely be nice if there were more information on _why_ a template
> constraint
> fails.
The case is analog to producing a sensible parsing error message in case of a
choice:
P : P1 | P2 | P3
The only solutions are to ignore the issue or to provide error messages for
every Pi. This gives for instance:
unittest{
auto a = character('a');
auto b = character('b');
auto c = character('c');
auto ch = choice(a, b, c)("ch");
ch.match("d");
}
==>
******************************************************************
Match Failure: cannot match expected pattern.
pattern : ch=('a'|'b'|'c')
index : 0
found : d
Failure reasons for sub-patterns:
******************************************************************
******************************************************************
Match Failure: cannot match expected pattern.
pattern : 'a'
index : 0
found : d
******************************************************************
******************************************************************
Match Failure: cannot match expected pattern.
pattern : 'b'
index : 0
found : d
******************************************************************
******************************************************************
Match Failure: cannot match expected pattern.
pattern : 'c'
index : 0
found : d
******************************************************************
(Actually, the parsing lib does not yet indent sub-pattern error messages -- I
cheated.)
I guess a similar scheme can be used for template error messages (when _all_
versions fail).
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com