DryChem 1.0.0
A generic, compile-time C++ toolbox with no dependencies for the modern computational chemistry project.
Loading...
Searching...
No Matches
CppUtils::Math::Vector3D< T, typename > Class Template Reference

#include <vector3D.hpp>

Inheritance diagram for CppUtils::Math::Vector3D< T, typename >:
CppUtils::Operators::CompletelyComparable< Vector3D< T > >

Public Types

using value_type = T
 Member types.
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using reference = typename std::array<T, 3>::reference
 
using const_reference = typename std::array<T, 3>::const_reference
 
using pointer = typename std::array<T, 3>::pointer
 
using const_pointer = typename std::array<T, 3>::const_pointer
 
using iterator = typename std::array<T, 3>::iterator
 
using const_iterator = typename std::array<T, 3>::const_iterator
 
using container_type = std::array<T, 3>
 With this member type, we are now both a container and container adapter.
 

Public Member Functions

constexpr Vector3D () noexcept=default
 Constructors.
 
constexpr Vector3D (T x_, T y_, T z_) noexcept
 
constexpr Vector3D (const container_type &data_) noexcept
 
constexpr reference at (size_type pos_)
 Element access - reuse the definitions from the internal array.
 
constexpr const_reference at (size_type pos_) const
 Could throw: array::at.
 
constexpr reference operator[] (size_type pos_) noexcept
 Could throw: array::at.
 
constexpr const_reference operator[] (size_type pos_) const noexcept
 
constexpr iterator begin () noexcept
 Iterators - reuse the definitions from the internal array.
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr iterator end () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr bool empty () const noexcept
 Capacity - these are fixed due to our definition of the internal array.
 
constexpr size_type size () const noexcept
 
constexpr size_type max_size () const noexcept
 
constexpr void fill (const_reference value_)
 Operations - reuse the definitions from the internal array.
 
constexpr void swap (Vector3D< T > &other_)
 

Private Attributes

std::array< T, 3 > data {}
 

Friends

constexpr friend bool operator== (const Vector3D< T > &lhs_, const Vector3D< T > &rhs_)
 Comparison operators - reuse the definitions from the internal array.
 
constexpr friend bool operator< (const Vector3D< T > &lhs_, const Vector3D< T > &rhs_)
 

Detailed Description

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
class CppUtils::Math::Vector3D< T, typename >

A container adapter class for a mathematical/physical vector with three dimensions: x, y, z. For the most part, the functionality is delegated to the internal std::array<> and the type is defined using the tuple-like API so it can be used with structured bindings.

Template Parameters
T- The type of the value we are storing in the Vector3D, must be default constructible
Todo
Add arithmetic operators (possibly using expression templates)
Note
The reverse iterators were not added to the interface because I didn't see a need for them at the time. If they are needed, they should be simple to add back in.

Member Typedef Documentation

◆ value_type

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::value_type = T

◆ size_type

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::size_type = std::size_t

◆ difference_type

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::difference_type = std::ptrdiff_t

◆ reference

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::reference = typename std::array<T, 3>::reference

◆ const_reference

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::const_reference = typename std::array<T, 3>::const_reference

◆ pointer

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::pointer = typename std::array<T, 3>::pointer

◆ const_pointer

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::const_pointer = typename std::array<T, 3>::const_pointer

◆ iterator

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::iterator = typename std::array<T, 3>::iterator

◆ const_iterator

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::const_iterator = typename std::array<T, 3>::const_iterator

◆ container_type

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
using CppUtils::Math::Vector3D< T, typename >::container_type = std::array<T, 3>

Constructor & Destructor Documentation

◆ Vector3D() [1/3]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
CppUtils::Math::Vector3D< T, typename >::Vector3D ( )
constexprdefaultnoexcept

Referenced by operator<, operator==, swap(), and Vector3D().

◆ Vector3D() [2/3]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
CppUtils::Math::Vector3D< T, typename >::Vector3D ( T x_,
T y_,
T z_ )
inlineconstexprnoexcept

References data, and Vector3D().

◆ Vector3D() [3/3]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
CppUtils::Math::Vector3D< T, typename >::Vector3D ( const container_type & data_)
inlineexplicitconstexprnoexcept

References data.

Member Function Documentation

◆ at() [1/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
reference CppUtils::Math::Vector3D< T, typename >::at ( size_type pos_)
inlineconstexpr

References data.

◆ at() [2/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_reference CppUtils::Math::Vector3D< T, typename >::at ( size_type pos_) const
inlineconstexpr

References data.

◆ operator[]() [1/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
reference CppUtils::Math::Vector3D< T, typename >::operator[] ( size_type pos_)
inlineconstexprnoexcept

References data.

◆ operator[]() [2/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_reference CppUtils::Math::Vector3D< T, typename >::operator[] ( size_type pos_) const
inlineconstexprnoexcept

References data.

◆ begin() [1/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
iterator CppUtils::Math::Vector3D< T, typename >::begin ( )
inlineconstexprnoexcept

References data.

◆ begin() [2/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_iterator CppUtils::Math::Vector3D< T, typename >::begin ( ) const
inlineconstexprnoexcept

References data.

◆ cbegin()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_iterator CppUtils::Math::Vector3D< T, typename >::cbegin ( ) const
inlineconstexprnoexcept

References data.

◆ end() [1/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
iterator CppUtils::Math::Vector3D< T, typename >::end ( )
inlineconstexprnoexcept

References data.

◆ end() [2/2]

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_iterator CppUtils::Math::Vector3D< T, typename >::end ( ) const
inlineconstexprnoexcept

References data.

◆ cend()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
const_iterator CppUtils::Math::Vector3D< T, typename >::cend ( ) const
inlineconstexprnoexcept

References data.

◆ empty()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
bool CppUtils::Math::Vector3D< T, typename >::empty ( ) const
inlineconstexprnoexcept

◆ size()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
size_type CppUtils::Math::Vector3D< T, typename >::size ( ) const
inlineconstexprnoexcept

◆ max_size()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
size_type CppUtils::Math::Vector3D< T, typename >::max_size ( ) const
inlineconstexprnoexcept

◆ fill()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
void CppUtils::Math::Vector3D< T, typename >::fill ( const_reference value_)
inlineconstexpr

References data.

◆ swap()

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
void CppUtils::Math::Vector3D< T, typename >::swap ( Vector3D< T > & other_)
inlineconstexpr

References data, and Vector3D().

Friends And Related Symbol Documentation

◆ operator==

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
friend bool operator== ( const Vector3D< T > & lhs_,
const Vector3D< T > & rhs_ )
friend

References data, and Vector3D().

◆ operator<

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
friend bool operator< ( const Vector3D< T > & lhs_,
const Vector3D< T > & rhs_ )
friend

References data, and Vector3D().

Member Data Documentation

◆ data

template<typename T, typename = std::enable_if_t<std::is_default_constructible_v<T>>>
std::array<T, 3> CppUtils::Math::Vector3D< T, typename >::data {}
private

The documentation for this class was generated from the following file: