MCPcopy Create free account
hub / github.com/changkun/modern-cpp-tutorial / _tuple_index

Function _tuple_index

code/4/4.3.cpp:27–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <size_t n, typename... T>
27boost::variant<T...> _tuple_index(size_t i, const std::tuple<T...>& tpl) {
28 if (i == n)
29 return std::get<n>(tpl);
30 else if (n == sizeof...(T) - 1)
31 throw std::out_of_range("越界.");
32 else
33 return _tuple_index<(n < sizeof...(T)-1 ? n+1 : 0)>(i, tpl);
34}
35template <typename... T>
36boost::variant<T...> tuple_index(size_t i, const std::tuple<T...>& tpl) {
37 return _tuple_index<0>(i, tpl);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected