Loading…
|
Translation uploaded |
|
|
String added in the repository |
|
Things to check
Flags
safe-html, strict-same
Loading…
|
Translation uploaded |
|
|
String added in the repository |
|
Often it is needed to use several conversion contexts together. For example, consider a log of remote users identified by IP addresses accessing a system. We can represent it as通常需要同时使用多个转换上下文。例如,考虑一个记录远程用户(通过 IP 地址标识)访问系统的日志,我们可以将其表示为 `std::vector<std::pair<std::chrono::system_clock::time_point, ip_address>>`. We want to serialize both="">>`。我们希望将``ip_address``es and和``time_point``s as strings, but for this we need both都序列化为字符串,但这需要同时使用`as_string`and和`as_iso_8601`contexts. To combine several contexts just use {std_tuple}. Conversion functions will select the first element of the tuple for which a `tag_invoke` overload exists and will call that overload. As usual, `tag_invoke` overloads that don't use contexts and library-provided generic conversions are also supported. Thus, here's our example:两个上下文。要组合多个上下文,只需使用{std_tuple}。转换函数会从元组中选择第一个存在对应 `tag_invoke` 重载的元素,并调用该重载。与往常一样,不使用上下文的`tag_invoke`重载和库提供的通用转换也受支持。因此,我们的示例如下:</std::pair<std::chrono::system_clock::time_point,>