Skip to content

Commit

Permalink
fix(cpp) vector<< false positive as template begin (#3438)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Dec 29, 2021
1 parent c0138d9 commit 7355c13
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -15,6 +15,7 @@ These changes should be for the better and should not be super noticeable but if
Grammars:

- enh(php) add PHP 8.1 keywords [Wojciech Kania][]
- fix(cpp) fix `vector<<` template false positive (#3437) [Josh Goebel][]
- enh(php) support First-class Callable Syntax (#3427) [Wojciech Kania][]
- enh(php) support class constructor call (#3427) [Wojciech Kania][]
- enh(php) support function invoke (#3427) [Wojciech Kania][]
Expand Down
2 changes: 1 addition & 1 deletion src/languages/cpp.js
Expand Up @@ -558,7 +558,7 @@ export default function(hljs) {
[
PREPROCESSOR,
{ // containers: ie, `vector <int> rooms (9);`
begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function)\\s*<',
begin: '\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function)\\s*<(?!<)',
end: '>',
keywords: CPP_KEYWORDS,
contains: [
Expand Down
6 changes: 6 additions & 0 deletions test/markup/cpp/bugs.expect.txt
@@ -0,0 +1,6 @@
<span class="hljs-comment">//4. 对角矩阵</span>
<span class="hljs-comment">//4.1 构造对角矩阵</span>
<span class="hljs-function">Eigen::VectorXd <span class="hljs-title">vector</span><span class="hljs-params">(<span class="hljs-number">5</span>)</span></span>; <span class="hljs-comment">//构建5维向量</span>
vector&lt;&lt;<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>; <span class="hljs-comment">//向量赋值</span>
<span class="hljs-function">Eigen::MatrixXd <span class="hljs-title">C</span><span class="hljs-params">(vector.asDiagonal())</span></span>; <span class="hljs-comment">//使用向量生成对角阵</span>
std::cout &lt;&lt; <span class="hljs-string">&quot;\nC= \n&quot;</span> &lt;&lt; C &lt;&lt; std::endl;
6 changes: 6 additions & 0 deletions test/markup/cpp/bugs.txt
@@ -0,0 +1,6 @@
//4. 对角矩阵
//4.1 构造对角矩阵
Eigen::VectorXd vector(5); //构建5维向量
vector<<1,2,3,4,5; //向量赋值
Eigen::MatrixXd C(vector.asDiagonal()); //使用向量生成对角阵
std::cout << "\nC= \n" << C << std::endl;

0 comments on commit 7355c13

Please sign in to comment.