WIP: specify first example binding...

...but does not compile, since all of the fallback functions
will be instantiated, even while in fact we're overriding them
right away with something that *can* be compiled.

this prompts me to reconsider and question the basic approach
with closures for binding, while in fact what I am doing here
is to implement an ABC.
This commit is contained in:
Fischlurch 2016-03-19 17:09:16 +01:00
parent df8ca071a8
commit cb2a95627d
2 changed files with 15 additions and 3 deletions

View file

@ -403,13 +403,13 @@
static bool
default_contentMatch (GenNode const& spec, Elm const& elm)
{
//return spec.matches(elm);
return spec.matches(elm);
}
static Elm
default_construct_from_payload (GenNode const& spec)
{
//return spec.data.get<Elm>();
return spec.data.get<Elm>();
}
static bool

View file

@ -298,7 +298,19 @@ namespace test{
// now set up a binding to these opaque private structures...
auto mutator =
TreeMutator::build()
.attach (collection(target));
.attach (collection(target)
.constructFrom ([&](GenNode const& spec) -> Data
{
cout << "constructor invoked on "<<spec<<endl;
return {spec.idi.getSym(), render(spec.data)};
})
.matchElement ([&](GenNode const& spec, Data const& elm)
{
cout << "match? "<<spec.idi.getSym()<<"=?="<<elm.key<<endl;
return spec.idi.getSym() == elm.key;
}
)
);
}