C++14 でローカルクラスを返す関数
C++14 だとこんな愉快な事ができるのかーと思って書いてみた。
[ソース]
#include <iostream> template<typename T, typename U> constexpr auto make_person(T name, U age){ struct person{ T name; U age; }; return person{ name, age }; } int main(){ constexpr auto homu = make_person("homu", 14); static_assert(homu.age == 14, ""); std::cout << homu.name << std::endl; return 0; }