Skip to content

Commit 66b653b

Browse files
committed
Add documentation for user defined literal operator and usage
1 parent 607d681 commit 66b653b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

cpp/common/src/codingstandards/cpp/UserDefinedLiteral.qll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
import cpp
66

7+
/**
8+
* A user defined literal operator is a function that defines the behavior of a user defined literal.
9+
* It is declared using the `operator ""` syntax.
10+
* ```
11+
* constexpr long operator""_km(unsigned long value) {
12+
* ...
13+
* }
14+
* ```
15+
*/
716
class UserDefinedLiteralDeclaration extends Function {
817
UserDefinedLiteralDeclaration() {
918
// We use the '?' in this regexp because CodeQL CLI 2.4.6 and earlier reported these operators
@@ -17,6 +26,12 @@ class UserDefinedLiteralDeclaration extends Function {
1726
predicate hasCompliantSuffix() { this.getName().regexpMatch("operator \"\"?_\\p{Alpha}+") }
1827
}
1928

29+
/**
30+
* A user defined literal is a literal that is passed as an argument to a call to a user defined literal operator.
31+
* ```
32+
* 1000_km;
33+
* ```
34+
*/
2035
class UserDefinedLiteral extends Literal {
2136
UserDefinedLiteral() {
2237
exists(FunctionCall fc |

0 commit comments

Comments
 (0)