filename() field should be const std::string* not std::string*
Martin Blais <[email protected]>
| Newsgroups | gmane.comp.parsers.bison.general |
|---|---|
| Message-ID | <CAK21+hNVZCV5yf211nx9DPr7vUQ6EueTwjLE3iHAB22NAWRZow@mail.gmail.com> |
Dear grammar-generators, I'm setting up my %initial-action directive this morning (so much fun) and I can't help notice that the C++ location() and position() constructors and initializers accept an "std::string*" and not a "const std::string*", despite not modifying their value anywhere. The docs on the "position" class say: Instance Variable of position: std::string* file The name of the file. It will always be handled as a pointer, the parser will never duplicate nor deallocate it. As an experimental feature you may change it to ‘type*’ using ‘%define filename_type "type"’. The generated parser doesn't seem to modify it. This forces by driver object to cast away what should otherwise be a comforting const access. I can "fix" this by using %define filename_type "const std::string" Is there any reason not to make the default const? Thank you,