Skip to content

Commit

Permalink
enh(cpp) support parameter packs in function decls (#2918)
Browse files Browse the repository at this point in the history
Resolves #2917.
  • Loading branch information
mortie authored Dec 15, 2020
1 parent a6083b2 commit 1846044
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,4 @@ Contributors:
- Marcus Ortiz <mportiz08@gmail.com>
- Guillaume Grossetie <ggrossetie@yuzutech.fr>
- Steven Van Impe <steven.vanimpe@icloud.com>
- Martin Dørum <martid0311@gmail.com>
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ New Languages:

Language improvements:

- enh(cpp): Support C++ pack expansion in function arguments [Martin Dørum][]
- enh(makefile): Add `make` as an alias (#2883) [tripleee][]
- fix(http) avoid recursive sublanguage and tighten rules (#2893) [Josh Goebel][]
- enh(swift) Improved grammar for strings (#2819) [Steven Van Impe][]
Expand All @@ -28,6 +29,7 @@ Grammar improvements:
- enh(dart) Fix empty doc-comment eating next line [Jan Pilzer][]
- enh(asciidoc) Adds support for unconstrained bold syntax (#2869) [Guillaume Grossetie][]

[Martin Dørum]: https://github.com/mortie
[Jan Pilzer]: https://github.com/Hirse
[Oldes Huhuman]: https://github.com/Oldes
[Josh Goebel]: https://github.com/joshgoebel
Expand Down
2 changes: 1 addition & 1 deletion src/languages/c-like.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export default function(hljs) {
end: /[{;=]/,
excludeEnd: true,
keywords: CPP_KEYWORDS,
illegal: /[^\w\s\*&:<>]/,
illegal: /[^\w\s\*&:<>.]/,
contains: [
{ // to prevent it from being confused as the function title
begin: DECLTYPE_AUTO_RE,
Expand Down
4 changes: 4 additions & 0 deletions test/markup/cpp/function-declarations.expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
<span class="hljs-comment">// template</span>
<span class="hljs-function">boost::optional&lt;application&gt; <span class="hljs-title">handle_key</span><span class="hljs-params">(application state, key_code key, coord size)</span></span>;

<span class="hljs-comment">// pack expansion in function arguments</span>
<span class="hljs-function"><span class="hljs-keyword">template</span>&lt;<span class="hljs-keyword">typename</span> T...&gt;
<span class="hljs-keyword">void</span> <span class="hljs-title">foo</span><span class="hljs-params">(T... args)</span> </span>{}

test();
4 changes: 4 additions & 0 deletions test/markup/cpp/function-declarations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ B::type test() {};
// template
boost::optional<application> handle_key(application state, key_code key, coord size);

// pack expansion in function arguments
template<typename T...>
void foo(T... args) {}

test();

0 comments on commit 1846044

Please sign in to comment.