mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +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:
parent
fdb0ac7c1e
commit
b42c6ea281
|
@ -504,6 +504,9 @@ using CopyConst =
|
||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
using Void = void;
|
using Void = void;
|
||||||
|
|
||||||
|
template<typename... _Ignored>
|
||||||
|
inline constexpr auto DependentFalse = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using AK::AddConst;
|
using AK::AddConst;
|
||||||
|
@ -512,6 +515,7 @@ using AK::ceil_div;
|
||||||
using AK::clamp;
|
using AK::clamp;
|
||||||
using AK::Conditional;
|
using AK::Conditional;
|
||||||
using AK::declval;
|
using AK::declval;
|
||||||
|
using AK::DependentFalse;
|
||||||
using AK::exchange;
|
using AK::exchange;
|
||||||
using AK::forward;
|
using AK::forward;
|
||||||
using AK::is_trivial;
|
using AK::is_trivial;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <AK/Forward.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/NumericLimits.h>
|
#include <AK/NumericLimits.h>
|
||||||
|
#include <AK/StdLibExtras.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibIPC/Forward.h>
|
#include <LibIPC/Forward.h>
|
||||||
#include <LibIPC/Message.h>
|
#include <LibIPC/Message.h>
|
||||||
|
@ -37,8 +38,8 @@ namespace IPC {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool decode(Decoder&, T&)
|
inline bool decode(Decoder&, T&)
|
||||||
{
|
{
|
||||||
|
static_assert(DependentFalse<T>, "Base IPC::decoder() instantiated");
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Decoder {
|
class Decoder {
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace IPC {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool encode(Encoder&, T&)
|
bool encode(Encoder&, T&)
|
||||||
{
|
{
|
||||||
|
static_assert(DependentFalse<T>, "Base IPC::encode() was instantiated");
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue