Skip to content

match_results operator[] no longer accepts enums #265

@ymett

Description

@ymett

Pull request 208 Suppress conversion warnings in match_results broke the ability to pass an unscoped enum to match_results operator[] (and related functions).

This ability was particularly useful because it allowed giving expressive names to matches without having to number them individually (which is error prone).

E.g.:

enum { banana = 1, apple, orange };
boost::regex r("(banana)|(apple)|(orange)");

allowing
match[apple]

with the index value updating automatically when changing the regex (so long as the enum is updated to match).

Two possible fixes:

  1. Quick: Add an explicit test for enums
  2. Correct: Allow anything which converts implicitly to int, restoring earlier behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions