A lightweight, header-only fundamental type detection utility for C++11 and later.
primitive identifies fundamental C++ types, including cv-qualified fundamental types.
- C++11 or later
- CMake 3.16 or later for CMake integration
#include "primitive.h"
static_assert(primitive<int>::value, "fundamental type");
static_assert(!primitive<int*>::value, "pointer type");For more examples and API documentation, see Usage Documentation.
Download primitive.h from the repository and add it to your project's include directory.
Include the header using #include "primitive.h". No separate compilation is required.
primitive can be integrated directly from GitHub using CMake's FetchContent module.
Add the following to your project's CMakeLists.txt:
include(FetchContent)
FetchContent_Declare(
primitive
GIT_REPOSITORY https://github.com/DanielArndt0/primitive.git
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(primitive)
target_link_libraries(my_target PRIVATE primitive::primitive)Replace my_target with your application's CMake target.
If you already have the primitive source directory inside your CMake project, you can add it instead:
add_subdirectory(path/to/primitive)
target_link_libraries(my_target PRIVATE primitive::primitive)primitive is header-only and does not require a separately compiled binary.
primitive requires C++11 or later and uses the standard <type_traits> header.
primitive is developed for educational purposes and experimentation with template specialization. It is not intended to replace std::is_fundamental.