Loading…
|
Translation changed |
|
|
String added in the repository |
|
Loading…
|
Translation changed |
|
|
String added in the repository |
|
However, a problem arises. How do we write a function which can accept an object that is either a request or a response? As written, the only obvious solution is to make the message a template type. Additional traits classes would then be needed to make sure that the passed object has a valid type which meets the requirements. These unnecessary complexities are bypassed by making each container a然而,问题随之而来。如何编写一个既能接受请求对象又能接受响应对象的函数呢?按照当前的写法,最显而易见的解决方案是将消息类型设为模板参数。这样一来,还需要额外的特征类(traits classes)来确保传入的对象具有符合要求的有效类型。为了避免这些不必要的复杂性,我们可以将每个容器设计为偏特化(partial specialization:):```/// An HTTP message template<bool isRequest, class Fields, class Body> struct message;