Skip to content

Problems with underspecialized transform_attribute trait #450

Description

@Kojoley

Recently a lot of problems with make_attribute and transform_attribute traits were uncovered at fixing #444. I think the problem is that the trait does not have constrains, example:

template <typename Exposed, typename Transformed>
void post_transform(Exposed& dest, Transformed&& attr)
{
return transform_attribute<Exposed, Transformed, x3::parser_id>
::post(dest, std::forward<Transformed>(attr));
}

Because template parameter behind attr is a forwarding reference Transformed will be reference, but transform_attribute does not expect Transformed to be a reference and even const qualifier.

  • Add static assertions to catch passing references and const types to Transformed parameter.
  • Remove traits::pre_transform and traits::post_transform traits to be sure both pre and post uses the same transformation trait.
  • Possibly forbid references in Exposed parameter.

Update: It is not clear to me if const can never appear in Transformed, so will do not touch as for now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions