1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +00:00

LibIPC: Make IPC::encode() and ::decode() fail at compiletime when used

This would previously fail at runtime, and it would have zero indication
of what exactly went wrong.
Also adds `AK::DependentFalse<Ts...>', which is a...dependent false.
This commit is contained in:
AnotherTest 2020-10-03 16:26:09 +03:30 committed by Andreas Kling
parent fdb0ac7c1e
commit b42c6ea281
3 changed files with 7 additions and 1 deletions

View file

@ -28,6 +28,7 @@
#include <AK/Forward.h>
#include <AK/NumericLimits.h>
#include <AK/StdLibExtras.h>
#include <AK/String.h>
#include <LibIPC/Forward.h>
#include <LibIPC/Message.h>
@ -37,8 +38,8 @@ namespace IPC {
template<typename T>
inline bool decode(Decoder&, T&)
{
static_assert(DependentFalse<T>, "Base IPC::decoder() instantiated");
ASSERT_NOT_REACHED();
return false;
}
class Decoder {

View file

@ -34,6 +34,7 @@ namespace IPC {
template<typename T>
bool encode(Encoder&, T&)
{
static_assert(DependentFalse<T>, "Base IPC::encode() was instantiated");
ASSERT_NOT_REACHED();
}