Skip to content

Commit 2f4b19c

Browse files
committed
work
1 parent 3f30d90 commit 2f4b19c

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎cpp2rust/converter/converter_lib.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@ std::string GetFunctionBaseName(const clang::FunctionDecl *decl) {
11851185
if (decl->isOverloadedOperator()) {
11861186
return GetOverloadedOperator(decl);
11871187
}
1188+
if (auto *suffix = decl->getLiteralIdentifier()) {
1189+
return "operator_literal_" + suffix->getName().str();
1190+
}
11881191
return decl->getNameAsString();
11891192
}
11901193

‎tests/unit/operator_other_free.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ struct S {
66

77
S operator,(const S &a, const S &b) { return {a.v * 10 + b.v}; }
88

9+
long operator""_k(unsigned long long v) { return v * 1000; }
10+
11+
double operator""_half(long double v) { return v / 2; }
12+
913
int main() {
1014
S s{3}, t{4};
1115
assert((s, t).v == 34);
1216
assert((s, t, s).v == 343);
17+
18+
assert(2_k == 2000);
19+
assert(3.0_half == 1.5);
20+
assert(operator""_k(4) == 4000);
1321
return 0;
1422
}

0 commit comments

Comments
 (0)