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

Function get_student

code/4/4.3.cpp:14–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include <boost/variant.hpp>
13
14auto get_student(int id)
15{
16 if (id == 0)
17 return std::make_tuple(3.8, 'A', "张三");
18 if (id == 1)
19 return std::make_tuple(2.9, 'C', "李四");
20 if (id == 2)
21 return std::make_tuple(1.7, 'D', "王五");
22 // 返回类型被推断为 std::tuple<double, char, std::string>
23 return std::make_tuple(0.0, 'D', "null");
24}
25
26template <size_t n, typename... T>
27boost::variant<T...> _tuple_index(size_t i, const std::tuple<T...>& tpl) {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected