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

https://github.com/414owen/typedef-gen

Alias all the types!
https://github.com/414owen/typedef-gen

aliases cpp typedef

Last synced: over 1 year ago
JSON representation

Alias all the types!

Awesome Lists containing this project

README

          





Typedef-Gen


Generate typedefs programatically from a grammar file.

## WARNING

HUGELY EXPONENTIAL OUTPUT SIZE GROWTH. MAY FILL YOUR HARDDRIVE WITH TYPEDEFS IF
YOU WRITE A BAD GRAMMAR FILE OR USE LOTS OF LAYERS.

## Requirements

* g++
* make
* boost

## To build

```
make
```

## To run

```
./alias [ [ []]]

# eg.
./alias 2 grammar out
# or
./alias
```

## Sample output

```
typedef std::vector vc;
typedef std::vector vi;
typedef std::vector vll;
typedef std::map mcc;
typedef std::map mic;

...

typedef std::vector vvc;
typedef std::vector vvi;
typedef std::vector vvll;

...

typedef std::map mmcivc;
typedef std::map mmiivc;

...

and so on, all the way down to those master of types:

typedef std::tuple ttclllltlllllltllllll;
typedef std::tuple ttilllltlllllltllllll;
typedef std::tuple ttlllllltlllllltllllll;
```

## Notes

Naming conflicts are possible, for example, with this grammar file:

```
#include

long long -> ll
unsigned -> u
unsigned long long -> ull

std::tuple<2-3> t
```

### tl;dr

Rename `u` or `ull` so `ull` doesn't start with the former.

### Explanation

This is because `tullu` could mean `tuple`, or
`tuple` (notice the extra comma). The solution to
this is not to abbreviations that start with the whole of another abbreviation
(in this exmaple `ull` starts with `u`) in grammars which generate
multiple-arity template arguments (tuple can have two or three parameters).