An open API service indexing awesome lists of open source software.

https://github.com/theypsilon/getset

Add trivial getters & setters to your interface in a very simple and extensible way
https://github.com/theypsilon/getset

Last synced: about 1 year ago
JSON representation

Add trivial getters & setters to your interface in a very simple and extensible way

Awesome Lists containing this project

README

          

getset.hpp [![Build Status](https://travis-ci.org/theypsilon/getset.svg?branch=master)](https://travis-ci.org/theypsilon/getset)
======

```cpp
#include "getset.hpp"
#include

using namespace accessor;

struct Data {
getset a;
getset b;
getset c;
};

int main() {
Data x{"Hello","I'm not a blank space","World."};
x.b(" ");
std::cout << x.a() << x.b() << x.c() << std::endl;
return 0;
}

/* output: "Hello World." */
```

Just add this simple template to your types and you will have a getter & setter interface that eventually you will be able to modify in the future without any modification in client code.

This has **zero** overhead. You may compare the asm this code generates, with the one you get when you replace the getset statements with raw variable declarations and simple assignments.