Author
Dominic Koepke
Mail: DNKpp2011@gmail.com
License
BSL-1.0 (free, open source)
Copyright Dominic Koepke 2021 - 2022.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
https://www.boost.org/LICENSE_1_0.txt)
Description
This library provides an implementation of a simple to use but versatile mathematically vector class. Due to the usage of lots of c++20 features, this library currently doesn't compile on any clang compiler.
Tested Compilers:
- msvc v143 (Visual Studio 2022)
- gcc10
- gcc11
One of the main intentions behind this vector implementation is being able to do as much during compile-time as possible, thus all functions are declared as constexpr.
Example
#include <iostream>
#include <ranges>
int main()
{
Vector<int, 2> intVec1;
intVec1 += 2;
Vector<int, 2> intVec2{ 1, 3 };
Vector difference =
static_cast<Vector<float, 2>
>(intVec1 - intVec2);
auto distance =
length(difference);
auto tmp = difference.x();
tmp = difference.y();
tmp = difference[0];
for (auto el : difference)
{
std::cout << el << " ";
}
std::cout << std::endl;
for (auto el : intVec2 | std::views::take(1))
{
std::cout << el;
}
auto doubles2 = static_cast<Vector<double, 3>>(doubles);
}
constexpr auto length(const TVector &vector)
Calculates the length of a Vector.
Definition: Vector.hpp:657
Vector(T &&...) -> Vector< std::common_type_t< T... >, sizeof...(T)>
Vector deduction guide to make aggregate-like construction easier.
Installation with CMake
This library can easily be integrated into your project via CMake target_link_libraries command.
target_link_libraries(
<your_target_name>
PRIVATE
Simple-Vector::Simple-Vector
)
This will add the the include path "<simple_vector_install_dir>/include", thus you are able to include the headers via
FetchContent
It is possible fetching this library via CMakes FetchContent module.
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(<your_project_name>)
include(FetchContent)
FetchContent_Declare(
Simple_Vector
GIT_REPOSITORY https://github.com/DNKpp/Simple-Vector
GIT_TAG origin/vx.y.z
)
FetchContent_MakeAvailable(Simple_Vector)
target_link_libraries(
<your_target_name>
PUBLIC
Simple-Vector::Simple-Vector
)