changed track to use default param

This commit is contained in:
Pagwin 2024-12-11 13:15:25 -05:00
parent 474309ba49
commit 294b61072e
No known key found for this signature in database
GPG key ID: 81137023740CA260
2 changed files with 7 additions and 4 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
i
s
t
.clangd

View file

@ -1,5 +1,6 @@
#include <iostream>
#include <ostream>
// requires C++23 to compile
class A {
long long counter = 0;
@ -10,7 +11,8 @@ public:
ret.counter++;
return ret;
}
A operator[](int dummy) {
// requires C++23 to compile
A operator[](int _ = 0) {
A ret = *this;
ret.counter--;
return ret;
@ -23,8 +25,8 @@ public:
int main(void) {
A a;
std::cout << a[0] << std::endl;
std::cout << a[0]() << std::endl;
std::cout << a[0]()() << std::endl;
std::cout << a[] << std::endl;
std::cout << a[]() << std::endl;
std::cout << a[]()() << std::endl;
return 0;
}