Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
void is a fundamental, incomplete type in C++ that represents the intentional absence of a value or type. Because it is an incomplete type that can never be completed, objects of type void cannot be instantiated, and the type inherently possesses no size (evaluating sizeof(void) is ill-formed in standard C++).
In the C++ type system, void appears in several distinct syntactic contexts:
1. Function Return Type
When used as a return type, void specifies that a function terminates without yielding a value to the caller. A return statement within such a function must not include an expression, unless that expression itself evaluates to void.
void explicitly indicates that the function accepts no arguments. While standard in C, this syntax is retained in C++ strictly for backward compatibility; empty parentheses () are the semantic equivalent and the idiomatic C++ standard.
void*)
A void* is a pointer to an unspecified type. It stores a raw memory address but strips away all type information. Because the compiler does not know the size or layout of the underlying data, a void* cannot be directly dereferenced, nor can it participate in pointer arithmetic. It must be explicitly cast (typically via static_cast) to a typed pointer before the memory can be accessed.
void. This instructs the compiler to evaluate the expression strictly for its side effects and intentionally discard the resulting value.
void is a fully recognized type within the C++ type system, meaning it can be passed as a template type argument, aliased, or evaluated by type identification operators. This is heavily utilized in template metaprogramming to handle the absence of a type.
void:
- You cannot declare variables or class members of type
void. - You cannot create arrays of
void(e.g.,void arr[10];is ill-formed). - You cannot create references to
void(e.g.,void&is ill-formed). - You cannot create pointers-to-members of type
void(e.g.,void T::*is ill-formed).
<type_traits> library, void is identified by the std::is_void trait. It evaluates to true for void, as well as its cv-qualified variants: const void, volatile void, and const volatile void.
Master C++ with Deep Grasping Methodology!Learn More





