https://github.com/farnyser/cpp-sharpener
C++ with a C# flavor
https://github.com/farnyser/cpp-sharpener
cpp csharp transformer
Last synced: 6 days ago
JSON representation
C++ with a C# flavor
- Host: GitHub
- URL: https://github.com/farnyser/cpp-sharpener
- Owner: farnyser
- Created: 2017-03-07T20:18:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-07-16T18:37:06.000Z (almost 9 years ago)
- Last Synced: 2025-04-06T22:38:51.838Z (about 1 year ago)
- Topics: cpp, csharp, transformer
- Language: C++
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
C++ sharpener
==============
Mini project aiming to add some C# flavor to C++ !
Example
-------
Build a lambda C# style:
```c++
auto square = x => x * x;
std::cout << square(2) << std::endl; // output "4"
```
Simple named function:
```c++
int foobar() => 42;
```
Null-coalescing operator:
```c++
int a = 0;
std::cout << a ?? 3 << std::endl; // output "3"
```
Null-conditional operator:
```c++
struct foo { auto bar() => "hello !"; };
std::shared_ptr a = nullptr;
std::cout << (a?->bar() ?? "null") << std::endl; // output "null"
```
Build & Usage
------------
```shell
g++ -std=c++14 sharpener.cpp -o sharpener
cat examples/example.cpp | ./sharpener | g++ -xc++ -std=c++14 -o example -
./example
```