Show HN: C++ by Example – A new website for learning C++
cppbyexample.com18 pointsby shadedtriangle2 comments
using FormatArg = variant<int, float, string>;
string FormatArgs(const char* fmt, const vector<FormatArg> &args);
template <typename... Args>
string Format(const char* fmt, Args&&... args) {
vector<FormatArg> expanded_args = {args...};
return FormatArgs(fmt, expanded_args);
}
int main() {
cout << Format("Hello {} pi {}", "world", 3.14f);
}
https://godbolt.org/z/v5zo99aGe for (auto& [key, value] : persons)
The nested bindings are neat. Don’t think you can do that in c++ yet.