Order of parameter pack expansion

后端 未结 2 1527
眼角桃花
眼角桃花 2021-01-05 16:11

I have 2 functions to read binary file.

1st function reads sizeof(T) bytes from file:

template
T read() { ... some IO          


        
2条回答
  •  醉酒成梦
    2021-01-05 16:44

    I would keep it a bit simpler and do this:

    uint32_t a;
    uint8_t b;
    std::tie(a, b) = read>();
    

    This way there's only a single read() and you can even skip the tie() if you use the tuple (or struct) fields directly.

提交回复
热议问题