Skip to content

Commit b1ea418

Browse files
committed
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.
1 parent 421ebc2 commit b1ea418

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Userland/Libraries/LibIPC/Encoder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace IPC {
1717

1818
template<typename T>
19-
bool encode(Encoder&, T&)
19+
bool encode(Encoder&, T const&)
2020
{
2121
static_assert(DependentFalse<T>, "Base IPC::encode() was instantiated");
2222
VERIFY_NOT_REACHED();

Userland/Libraries/LibIPC/Forward.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ class Message;
1515
class File;
1616
class Stub;
1717

18+
template<typename T>
19+
bool encode(Encoder&, T const&);
20+
21+
template<typename T>
22+
ErrorOr<void> decode(Decoder&, T&);
23+
1824
}

0 commit comments

Comments
 (0)