# sol2 3.5.0 documentation

## as_returns

### Search the Documentation

# as_returns

turn an iterable argument into a multiple-return type

    template <typename T>
    struct as_returns_t { ... };

    template <typename T>
    as_returns_t<T> as_returns( T&& );

This allows you to wrap up a source that has `begin` and `end` iterator-returning functions on it and return it as multiple results into Lua. To have more control over the returns, use sol::variadic_results.

     1#define SOL_ALL_SAFETIES_ON 1
     2#include <sol/sol.hpp>
     3
     4
     5#include <string>
     6#include <set>
     7
     8int main() {
     9	sol::state lua;
    10
    11	lua.set_function("f", []() {
    12		std::set<std::string> results {
    13			"arf", "bark", "woof"
    14		};
    15		return sol::as_returns(std::move(results));
    16	});
    17
    18	lua.script("v1, v2, v3 = f()");
    19
    20	std::string v1 = lua["v1"];
    21	std::string v2 = lua["v2"];
    22	std::string v3 = lua["v3"];
    23
    24	SOL_ASSERT(v1 == "arf");
    25	SOL_ASSERT(v2 == "bark");
    26	SOL_ASSERT(v3 == "woof");
    27
    28	return 0;
    29}