bob@bob
something@something something@something.com
#include <chaiscript/chaiscript.hpp> | |
#include <chaiscript/chaiscript_stdlib.hpp> | |
std::string helloWorld(const std::string &t_name) | |
{ | |
return "Hello " + t_name + "!"; | |
} | |
int main() | |
{ |
#include <iostream> | |
#include <memory> | |
#include <vector> | |
#include <algorithm> | |
#include <type_traits> | |
template< class ... > using void_t = void; | |
template< class T , class = void > | |
struct is_dereferenceable : std::false_type |
// ChaiScript has its own simple object model and works well with object | |
// oriented C++ | |
// There is no difference between a function and a method, it's just syntactic sugar | |
var s = "mystring".size() // returns 8 | |
var s2 = size("mystring") // returns 8 | |
// class syntax |
// ChaiScript supports the normal kind of control blocks you've come to expect from | |
// C++ and JavaScript | |
if (5 > 2) { | |
print("Yup, 5 > 2"); | |
} else if (2 > 5) { | |
// never gonna happen | |
} else { | |
// really not going to happen |
#include <vector> | |
#include <string> | |
#include <sstream> | |
#include <iostream> | |
template<typename ... T> | |
std::vector<std::string> to_strings(const T& ... t) | |
{ | |
std::stringstream ss; | |
return { (ss.str(""), ss << t, ss.str())... }; |
#include <vector> | |
int main() | |
{ | |
// initialize a vector of integers. For the purposes of this example let's assume we *need* a vector | |
std::vector<int> v {1, 2, 3, 4, 5, 6, 1012, 1094}; | |
} |
repositories: | |
- "ChaiScript/ChaiScript" |
bob@bob
something@something something@something.com
// Generator class | |
class Generator | |
{ | |
var has_value; | |
var value_holder; | |
var params; | |
var func; | |
// empty Generator - no value contained |
var func = fun(){ | |
var ret = 0; | |
for (var i = 0; i < 1000000; ++i) { | |
ret += i; | |
} | |
return ret; | |
} | |
// async takes a 0 parameter function object which is run asynchronously and | |
// returns a Boxed_Value (ie, any value, including void, should work) |