# sol2 3.5.0 documentation

## sol2 (sol2, version 3.5)

### Search the Documentation

# sol2 (sol2, version 3.5)

a fast, simple C++ and Lua Binding

When you need to hit the ground running with Lua and C++, sol is the go-to framework for high-performance binding with an easy to use API.

## get going:

- tutorial: quick ‘n’ dirty
- tutorial
- errors
- supported compilers, binary size, compile time
- features
- functions
- usertypes
- containers
- threading
- customization traits
- api reference manual
- mentions
- benchmarks
- getting performance
- config and safety
- exceptions
- run-time type information (rtti)
- unicode transformation format handling
- build
- licenses
- origin

## connect

Come to the Github Issues! We’ve got a friendly community, and they can help you out or you can come just to talk about the things you are working on!

## support

You can support the project and other related endeavors in various ways.

This is a time-consuming effort, so individuals who donate get to:

- steer the direction and time spent on sol

- get their name put up in the CONTRIBUTORS list

- put something of their choice on sol2’s README or the documentation’s front page

## “I need feature X, maybe you have it?”

Take a look at the Features page: it links to much of the API. You can also just straight up browse the api or ease in with the tutorials. To know more about the implementation for usertypes, see here To know how function arguments are handled, see this note. Don’t see a feature you want? Send inquiries for support for a particular abstraction to the issues tracker.

## the basics:

Note

The code below and more examples can be found in the examples directory.

     1#define SOL_ALL_SAFETIES_ON 1
     2
     3#include <sol/sol.hpp>
     4
     5int main() {
     6	sol::state lua;
     7	int x = 0;
     8	lua.set_function("beep", [&x] { ++x; });
     9	lua.script("beep()");
    10	SOL_ASSERT(x == 1);
    11
    12	sol::function beep = lua["beep"];
    13	beep();
    14	SOL_ASSERT(x == 2);
    15
    16	return 0;
    17}

     1#define SOL_ALL_SAFETIES_ON 1
     2
     3#include <sol/sol.hpp>
     4
     5struct vars {
     6	int boop = 0;
     7
     8	int bop() const {
     9		return boop + 1;
    10	}
    11};
    12
    13int main() {
    14	sol::state lua;
    15	lua.new_usertype<vars>(
    16	     "vars", "boop", &vars::boop, "bop", &vars::bop);
    17	lua.script(
    18	     "beep = vars.new()\n"
    19	     "beep.boop = 1\n"
    20	     "bopvalue = beep:bop()");
    21
    22	vars& beep = lua["beep"];
    23	int bopvalue = lua["bopvalue"];
    24
    25	SOL_ASSERT(beep.boop == 1);
    26	SOL_ASSERT(lua.get<vars>("beep").boop == 1);
    27	SOL_ASSERT(beep.bop() == 2);
    28	SOL_ASSERT(bopvalue == 2);
    29
    30	return 0;
    31}

# Search

- Search Page