Skip to content

Commit 8e9d161

Browse files
C++: Added support for default comparison operator (#2426)
1 parent 91fdd0b commit 8e9d161

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

components/prism-cpp.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Prism.languages.cpp = Prism.languages.extend('c', {
66
'class-name': [
77
{
8-
pattern: RegExp(/(\b(?:class|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
8+
pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source
99
.replace(/<keyword>/g, function () { return keyword.source; })),
1010
lookbehind: true
1111
},
@@ -17,19 +17,16 @@
1717
// This will capture the class name before destructors like:
1818
// Foo::~Foo() {}
1919
/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
20-
{
21-
// This also intends to capture the class name of method implementations but here the class has template
22-
// parameters, so it can't be a namespace (until C++ adds generic namespaces).
23-
pattern: /\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/,
24-
inside: null // see below
25-
}
20+
// This also intends to capture the class name of method implementations but here the class has template
21+
// parameters, so it can't be a namespace (until C++ adds generic namespaces).
22+
/\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
2623
],
2724
'keyword': keyword,
2825
'number': {
2926
pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+\.?[\da-f']*|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+\.?[\d']*|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]*/i,
3027
greedy: true
3128
},
32-
'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
29+
'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
3330
'boolean': /\b(?:true|false)\b/
3431
});
3532

components/prism-cpp.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/cpp/class-name_feature.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Foo
22
class Foo_bar
3+
concept Foo_bar
34
struct foo
45
enum bar
56
enum class FooBar
@@ -14,6 +15,7 @@ void Foo<int>::bar() {}
1415
[
1516
["keyword", "class"], ["class-name", "Foo"],
1617
["keyword", "class"], ["class-name", "Foo_bar"],
18+
["keyword", "concept"], ["class-name", "Foo_bar"],
1719
["keyword", "struct"], ["class-name", "foo"],
1820
["keyword", "enum"], ["class-name", "bar"],
1921
["keyword", "enum"], ["keyword", "class"], ["class-name", "FooBar"],

tests/languages/cpp/operator_feature.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
! && ||
66
-> ::
77
? :
8-
= == != < > <= >=
8+
= == != < > <= >= <=>
99
and and_eq bitand bitor not not_eq or or_eq xor xor_eq
1010

1111
----------------------------------------------------
@@ -55,6 +55,7 @@ and and_eq bitand bitor not not_eq or or_eq xor xor_eq
5555
["operator", ">"],
5656
["operator", "<="],
5757
["operator", ">="],
58+
["operator", "<=>"],
5859

5960
["operator", "and"],
6061
["operator", "and_eq"],

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy