Vettable Pattern: Assess container vettability in C++ (Updated)

Published December 12, 2025

Vettable Pattern: Assess container vettability in C++ (Updated)

I: Abstract

The Vettable pattern instructs whether a container should be vetted or not, It comes of as handy in low-level/systems programming codebases. This blog post will talk about its usage in NeKernel.

When a vet fails, a fallback shall be provided. A fallback may be a function pointer or a function wrapper.

Vetting is very efficient when it comes to security and enforcing the software design, as it blocks non vettable or vettable containers from being used in some parts, or restricts usage to them.

Part One: The IsVettable concept.

template <typename Type, FallbackType OnFallback>
concept IsVettable = requires() {
  { Vettable<Type>::kValue ? TrueResult<Type>::kValue : OnFallback(PropertyResult<Type>::kValue) };
};

This guarantees that the object is vettable, otherwise the fallback gets called.

Part Three: The Method of Container Vettability.

The method of container vettability resides in the need to focus on where failure is critical, for example a UserProcess is subject to vetting, whereas an int is not.

III: Conclusion.

This simple pattern is easy and flexible, Although it may not fit every need of every project, the Vettable pattern is a good start for codebase harderning and the software design stage of a project. As it guarantees that rules are being followed in the codebase.

References: