boostorg / beast

HTTP and WebSocket built on Boost.Asio in C++11
http://www.boost.org/libs/beast
Boost Software License 1.0
4.35k stars 633 forks source link

Explicit instantation of websocket::stream fails #1279

Closed djarek closed 5 years ago

djarek commented 5 years ago

https://wandbox.org/permlink/NhmB6f9y3wanpVdz

vinniefalco commented 5 years ago

Well, this is kind of tricky, because pmd_opts_ is not present if deflateSupported==false. But with explicit instantiation, the compiler has to emit both functions just in case. One solution is to just put pmd_opts_ in the declaration even if it isn't needed. I don't know what else to do. @glenfe ?

vinniefalco commented 5 years ago

Some light reading: https://stackoverflow.com/questions/40183520/explicit-template-instantiation-and-sfinae

djarek commented 5 years ago

@vinniefalco I believe that if open_pmd used SFINAE, this problem would go away, because the compiler wouldn't try to instantiate both.

vinniefalco commented 5 years ago

it has to instantiate both, how does it know ahead of time which one it will need?

djarek commented 5 years ago

https://godbolt.org/z/QltKnm

vinniefalco commented 5 years ago

This will help people reduce their build times by putting the definitions in a .cpp file instead of the .hpp.