Re: Static polymorphism
On Mar 22, 11:19 am, Olaf <o...@mdcc.de> wrote:
template<typename DerivedT, typename ActionsT>
struct check_policy
{
[...]
struct on_data_ver_action
{
[...]
};
const on_data_ver_action on_data_ver;
...
};
template <typename ActionsT = parse_actions,
template <typename, typename>
class CheckPolicyT = check_policy,
typename ErrorHandlerT = parse_error_handler>
struct grammar :
sp::grammar<
grammar<ActionsT, CheckPolicyT, ErrorHandlerT>
>
{
[...]
template <typename ScannerT>
struct definition
: CheckPolicyT< definition<ScannerT>, ActionsT >
{
...
explicit definition( const grammar& self )
: CheckPolicyT< definition<ScannerT>, ActionsT >(
self.actions )
{
[...]
document
= g(
expect_data_ver(
data_ver_p[on_data_ver]
error: 'on_data_ver' was not declared in this scope
This is already beyond my template knowledge :) Here is my guess:
on_data_ver is not known when the template is compiled. It is just an
unknown name at that time. It may be known when the template is
instantiated.
This solved the problem for g++:
typedef CheckPolicyT< definition<ScannerT>, ActionsT > Parent;
/* ... */ data_ver_p[Parent::on_data_ver]
I guess that way, the name becomes dependent on one of the template
parameters and the compiler delays the resolution to instantiation
time. (This sounds technical, but I wouldn't rely on it! :) )
Ali