# sol2 3.5.0 documentation

## tie

### Search the Documentation

# tie

improved version of std::tie

std::tie() does not work well with sol::function’s `sol::function_result` returns. Use `sol::tie` instead. Because they’re both named tie, you’ll need to be explicit when you use sol’s by naming it with the namespace (`sol::tie`), even with a `using namespace sol;`. Here’s an example:

     1#define SOL_ALL_SAFETIES_ON 1
     2#include <sol/sol.hpp>
     3
     4
     5int main(int, char*[]) {
     6
     7	const auto& code = R"(
     8	bark_power = 11;
     9
    10	function woof ( bark_energy )
    11		return (bark_energy * (bark_power / 4))
    12	end
    13)";
    14
    15	sol::state lua;
    16
    17	lua.script(code);
    18
    19	sol::function woof = lua["woof"];
    20	double numwoof = woof(20);
    21	SOL_ASSERT(numwoof == 55.0);
    22
    23	lua.script("function f () return 10, 11, 12 end");
    24
    25	sol::function f = lua["f"];
    26	std::tuple<int, int, int> abc = f();
    27	SOL_ASSERT(std::get<0>(abc) == 10);
    28	SOL_ASSERT(std::get<1>(abc) == 11);
    29	SOL_ASSERT(std::get<2>(abc) == 12);
    30	// or
    31	int a, b, c;
    32	sol::tie(a, b, c) = f();
    33	SOL_ASSERT(a == 10);
    34	SOL_ASSERT(b == 11);
    35	SOL_ASSERT(c == 12);
    36
    37	return 0;
    38}