From 362d792afcbd3a08af79b42dff3a3653f668b3ce Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 22 Dec 2025 11:58:03 +0100 Subject: feat: Improve code example in WG01. Signed-off-by: Amlal El Mahrouss --- source/wg01/wg01.tex | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/wg01/wg01.tex b/source/wg01/wg01.tex index 734ed28..f52154d 100644 --- a/source/wg01/wg01.tex +++ b/source/wg01/wg01.tex @@ -147,30 +147,30 @@ If two of the three conditions fail, then the framework fails, and you should co The following concept makes sure that the `class T' is vetted by the domain. Such properties are called `Vettable' such program in the domain makes sure that a `Container' is truly deemed fit for a Run-Time or Compile-Time Evaluation Domain. The `IVettable' structure makes use of template meta-programming in C++ to evaluate whether a `Container' shall be vetted, such containers inherit the `IVettable' structure and are marked final. Such system may look like this in a Compile-Time Evaluation Domain: \begin{lstlisting} -struct IVettable { - explicit IVettable() = default; - virtual ~IVettable() = default; - - NE_COPY_DEFAULT(IVettable) -}; +#define NE_VETTABLE static constexpr BOOL kVettable = YES; +#define NE_NON_VETTABLE static constexpr BOOL kVettable = NO; template -struct Vettable final { - static constexpr bool kValue = false; +concept IsVettable = requires(Type) { + (Type::kVettable); }; -template <> -struct Vettable final { - static constexpr bool kValue = true; +/// This structure is vettable. +struct UnVettable { + NE_VETTABLE; }; -template -using FallbackType = Void (*)(const PropertyResult& type_value); - -template OnFallback> -concept IsVettable = requires() { - { Vettable::kValue ? TrueResult{} : OnFallback(PropertyResult{}) }; +/// This structure is unvettable. +struct UnVettable { + NE_NON_VETTABLE; }; + +/// One example of a usage. +if constexpr (IsVettable) { + instVet->Vet(); +} else { + instVet->Abort(); +} \end{lstlisting} Source: \href{https://github.com/nekernel-org/nekernel/blob/develop/src/kernel/NeKit/Vettable.h}{Link}. \\Note: This is one approach to compile time vetting, one may solve this using tags instead of a base `IVettable' class. \section{Conclusion} -- cgit v1.2.3