From fc7b66642959e7de19aade010b6ebc1e59ba4b7a Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 27 Jan 2017 19:24:27 +0000 Subject: [PATCH] Add optional methods like yx(), x1(), x0() etc... You need to define VWR_EXTRA_ACCESSORS if you want those to be available in your build. --- include/vectorwrapper/vectorwrapper.hpp | 18 ++++++++++++++++++ test/unit/CMakeLists.txt | 1 + 2 files changed, 19 insertions(+) diff --git a/include/vectorwrapper/vectorwrapper.hpp b/include/vectorwrapper/vectorwrapper.hpp index 3f42e1c..5b7e364 100644 --- a/include/vectorwrapper/vectorwrapper.hpp +++ b/include/vectorwrapper/vectorwrapper.hpp @@ -281,6 +281,16 @@ namespace vwr { scalar_type& x ( void ); scalar_type& y ( void ); scalar_type& z ( void ); + +#if defined(VWR_EXTRA_ACCESSORS) + Vec xy0 ( void ) const { return Vec(x(), y(), scalar_type(0)); } + Vec xy1 ( void ) const { return Vec(x(), y(), scalar_type(1)); } + Vec x0z ( void ) const { return Vec(x(), scalar_type(0), z()); } + Vec x1z ( void ) const { return Vec(x(), scalar_type(1), z()); } + Vec _0yz ( void ) const { return Vec(scalar_type(0), y(), z()); } + Vec _1yz ( void ) const { return Vec(scalar_type(1), y(), z()); } + Vec zxy ( void ) const { return Vec(z(), x(), y()); } +#endif }; template @@ -291,6 +301,14 @@ namespace vwr { const scalar_type& y ( void ) const; scalar_type& x ( void ); scalar_type& y ( void ); + +#if defined(VWR_EXTRA_ACCESSORS) + Vec x0 ( void ) const { return Vec(x(), scalar_type(0)); } + Vec x1 ( void ) const { return Vec(x(), scalar_type(1)); } + Vec yx ( void ) const { return Vec(y(), x()); } + Vec _0y ( void ) const { return Vec(scalar_type(0), y()); } + Vec _1y ( void ) const { return Vec(scalar_type(1), y()); } +#endif }; template diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 0b65f23..52abae0 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -15,6 +15,7 @@ target_link_libraries(${PROJECT_NAME} target_compile_definitions(${PROJECT_NAME} PRIVATE VWR_WITH_IMPLICIT_CONVERSIONS + PRIVATE VWR_EXTRA_ACCESSORS ) add_test(