Skip to content

Commit bd9615e

Browse files
committed
Better readme, better examples, all better - cosmetics
1 parent 2d789b3 commit bd9615e

21 files changed

Lines changed: 3370 additions & 3321 deletions

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
11
# poly-var-cpp
22
Just-for-fun implementation of polymorphic variables in C/C++
3+
4+
## Usage
5+
6+
Clone the repository, go to the directory where it's placed
7+
and do `make` to get information about functionality of makefile.
8+
9+
If you want to compile all examples do `make all`
10+
And then run any of the examples by running `make run-example-aritm`, `make run-example-tree` etc.
11+
12+
The basic usage looks like this:
13+
14+
```c++
15+
#include <var>
16+
using namespace variable;
17+
18+
int main() {
19+
var x = 0;
20+
x += "2.5";
21+
cout<<x<<"\n";
22+
23+
return 0;
24+
}
25+
```
26+
27+
Or if you want to use printf/scanf style:
28+
29+
```c++
30+
#include <var>
31+
using namespace variable;
32+
33+
int main() {
34+
var x = 0;
35+
x += "2.5";
36+
printf("%d", (int)x);
37+
38+
return 0;
39+
}
40+
```
41+
42+
You can read the standard input too (floats for example):
43+
44+
```c++
45+
var x;
46+
cin >> x.castToFloat();
47+
```
48+
49+
Or:
50+
```c++
51+
var x;
52+
scanf("%f", (float*)x);
53+
```
54+
55+
56+
## More examples
57+
58+
Checkout examples/src for details about functionality of the module.
59+
Also you can see ./include/var.h to get more details.

examples/src/aritm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/custom_struct.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/generic_sorting.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/hashmap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/performance1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/sorting.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

examples/src/tree.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#include <var.h>
2-
#include <var_math.h>
3-
#include <var_test.h>
1+
#include <var>
2+
#include <var_math>
3+
#include <var_test>
44

55
using namespace variable;
66

include/var

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#define USE_DEFAULT_STRING_BEHAVIOUR
2+
#define NAMESPACE_VAR_BEGIN__ namespace variable {
3+
#define NAMESPACE_VAR_END__ };
4+
5+
#define var_funct_decl(CODE) ((std::function<var(var)>)([&](var args)->var CODE))
6+
7+
#include "var_custom_objects.h"
8+
#include "var.h"
9+
#include "var_basic_utilities.cpp"
10+
#include "var.cpp"
11+
#include "var_operator_toolkit.cpp"

0 commit comments

Comments
 (0)