1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

LibIPC: Forward declare the encode() and decode() template functions

For the most part, we try to provide specializations of these functions
in various headers by including "LibIPC/Forward.h" and then declaring
encode() and decode() specializations. However, without any forward
declaration of these types, we aren't actually specializing anything.
Rather, we are just declaring overloads, which trips up the base encode
and decode template definitions.

The result is that LibIPC is very sensitive to include order, and the
DependentFalse<> static assertion would fail if the includes weren't
perfectly ordered.

By properly forward declaring these templates, we can make sure the
specializations receive precedence over the base templates.
This commit is contained in:
Timothy Flynn 2022-11-15 10:01:23 -05:00 committed by Tim Flynn
parent 421ebc2e29
commit b1ea418d14
2 changed files with 7 additions and 1 deletions

View file

@ -16,7 +16,7 @@
namespace IPC { namespace IPC {
template<typename T> template<typename T>
bool encode(Encoder&, T&) bool encode(Encoder&, T const&)
{ {
static_assert(DependentFalse<T>, "Base IPC::encode() was instantiated"); static_assert(DependentFalse<T>, "Base IPC::encode() was instantiated");
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();

View file

@ -15,4 +15,10 @@ class Message;
class File; class File;
class Stub; class Stub;
template<typename T>
bool encode(Encoder&, T const&);
template<typename T>
ErrorOr<void> decode(Decoder&, T&);
} }