Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7355c13

Browse files
authored
fix(cpp) vector<< false positive as template begin (#3438)
1 parent c0138d9 commit 7355c13

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ These changes should be for the better and should not be super noticeable but if
1515
Grammars:
1616

1717
- enh(php) add PHP 8.1 keywords [Wojciech Kania][]
18+
- fix(cpp) fix `vector<<` template false positive (#3437) [Josh Goebel][]
1819
- enh(php) support First-class Callable Syntax (#3427) [Wojciech Kania][]
1920
- enh(php) support class constructor call (#3427) [Wojciech Kania][]
2021
- enh(php) support function invoke (#3427) [Wojciech Kania][]

src/languages/cpp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ export default function(hljs) {
558558
[
559559
PREPROCESSOR,
560560
{ // containers: ie, `vector <int> rooms (9);`
561-
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*<',
561+
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*<(?!<)',
562562
end: '>',
563563
keywords: CPP_KEYWORDS,
564564
contains: [

test/markup/cpp/bugs.expect.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<span class="hljs-comment">//4. 对角矩阵</span>
2+
<span class="hljs-comment">//4.1 构造对角矩阵</span>
3+
<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>
4+
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>
5+
<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>
6+
std::cout &lt;&lt; <span class="hljs-string">&quot;\nC= \n&quot;</span> &lt;&lt; C &lt;&lt; std::endl;

test/markup/cpp/bugs.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//4. 对角矩阵
2+
//4.1 构造对角矩阵
3+
Eigen::VectorXd vector(5); //构建5维向量
4+
vector<<1,2,3,4,5; //向量赋值
5+
Eigen::MatrixXd C(vector.asDiagonal()); //使用向量生成对角阵
6+
std::cout << "\nC= \n" << C << std::endl;

0 commit comments

Comments
 (0)