Skip to content

Instantly share code, notes, and snippets.

@WSSDude
WSSDude / GenericVectorMathC++20Demo.hpp
Last active August 4, 2024 22:01
Generic Vector Math Using C++20 Demo
// SPDX-License-Identifier: Unlicense
// Created by Andrej Redeky © 2024.
//
// Demo of how we could use the C++20 to generalize common vector math. It works with basic
// standard vector structures with 2-4 dimensions via pre-defined Vector2D-Vector4D, and also
// with vectors with some arbitrary number of dimensions via pre-defined VectorND. All of the
// demo structures are fully generic, supporting any scalar type. The demo heavily relies on
// auto-vectorization features of the compiler to generate optimal code for different cases
// without the need to manually use different SIMD intrinsics for different architectures.
//