diff --git a/source/parse.h b/source/parse.h index 0a3c792ef..0a2740aee 100644 --- a/source/parse.h +++ b/source/parse.h @@ -167,7 +167,7 @@ struct primary_expression_node auto is_literal() const -> bool; - auto template_arguments() const -> std::vector&; + auto template_arguments() const -> std::vector const&; auto get_token() const -> token const*; @@ -1024,11 +1024,10 @@ struct template_argument auto to_string() const -> std::string; - - // So that template_arguments() accessors can return a reference to an empty arg list - static inline std::vector no_template_args; }; +// Used by functions that must return a reference to an empty arg list +inline std::vector const no_template_args; struct unqualified_id_node { @@ -1040,8 +1039,8 @@ struct unqualified_id_node std::vector template_args; - auto template_arguments() - -> std::vector& + auto template_arguments() const + -> std::vector const& { return template_args; } @@ -1104,7 +1103,7 @@ struct qualified_id_node std::vector ids; auto template_arguments() const - -> std::vector& + -> std::vector const& { return ids.back().id->template_arguments(); } @@ -1223,7 +1222,7 @@ struct type_id_node } auto template_arguments() const - -> std::vector& + -> std::vector const& { if (id.index() == unqualified) { return std::get(id)->template_arguments(); @@ -1467,7 +1466,7 @@ struct id_expression_node > id; auto template_arguments() const - -> std::vector& + -> std::vector const& { if (is_unqualified()) { return std::get(id)->template_arguments(); @@ -3641,13 +3640,13 @@ auto function_type_node::is_destructor() const auto primary_expression_node::template_arguments() const - -> std::vector& + -> std::vector const& { if (expr.index() == id_expression) { return std::get(expr)->template_arguments(); } // else - return template_argument::no_template_args; + return no_template_args; }