Code Monkey home page Code Monkey logo

poly-var-cpp's Introduction

Polymorphic variables in C++

Made by Styczynsky Digital Systems

Platform - Node

Just-for-fun implementation of polymorphic variables in C/C++

#include <var>
#include <var_math>
#include <var_test>
using namespace variable;

int main(void) {

  /* Constructing a polymorphic-type tree */
	var hmap = var::Hashmap;
	hmap["foo"] = "bar";

	var a = hmap.ref();
	var ref = {a.ref(), 42};
	var ref2 = {ref.ref(), 69, 25};
	var tree = { {{}, 12, {}}, "ala", {{}, 69, {}} };

  vardbg(tree);

	return 0;
}

Usage

Clone the repository, go to the directory where it's placed and do make to get information about functionality of makefile.

If you want to compile all examples do make all And then run any of the examples by running make run-example-aritm, make run-example-tree etc.

The basic usage looks like this:

#include <var>
using namespace variable;

int main() {
  var x = 0;
  x += "2.5";
  cout<<x<<"\n";

  return 0;
}

Or if you want to use printf/scanf style:

#include <var>
using namespace variable;

int main() {
  var x = 0;
  x += "2.5";
  printf("%d", (int)x);

  return 0;
}

You can read the standard input too (floats for example):

  var x;
  cin >> x.castToFloat();

Or:

  var x;
  scanf("%f", (float*)x);

More examples

Checkout examples/src for details about functionality of the module. Also you can see ./include/var.h to get more details.

poly-var-cpp's People

Contributors

styczynski avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.