From c5c982a9a431e26493413d71106660fcd7d3038e Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Sun, 4 Apr 2021 14:42:37 +0200 Subject: [PATCH] Add optional set_*() methods. Useful if you need a setter/getter pair, for example to register them into some other library. --- include/vectorwrapper/vectorwrapper.hpp.in | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/vectorwrapper/vectorwrapper.hpp.in b/include/vectorwrapper/vectorwrapper.hpp.in index 3c31e24..b3de476 100644 --- a/include/vectorwrapper/vectorwrapper.hpp.in +++ b/include/vectorwrapper/vectorwrapper.hpp.in @@ -138,6 +138,13 @@ namespace vwr { scalar_type& z ( void ); scalar_type& w ( void ); +#if defined(VWR_EXTRA_SETTERS) + void set_x (const scalar_type& v) { x() = v; } + void set_y (const scalar_type& v) { y() = v; } + void set_z (const scalar_type& v) { z() = v; } + void set_w (const scalar_type& v) { w() = v; } +#endif + #if defined(VWR_EXTRA_ACCESSORS) Vec xyz0 ( void ) const { return Vec(x(), y(), z(), scalar_type(0)); } Vec xyz1 ( void ) const { return Vec(x(), y(), z(), scalar_type(1)); } @@ -164,6 +171,12 @@ namespace vwr { scalar_type& y ( void ); scalar_type& z ( void ); +#if defined(VWR_EXTRA_SETTERS) + void set_x (const scalar_type& v) { x() = v; } + void set_y (const scalar_type& v) { y() = v; } + void set_z (const scalar_type& v) { z() = v; } +#endif + #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)); } @@ -184,6 +197,11 @@ namespace vwr { scalar_type& x ( void ); scalar_type& y ( void ); +#if defined(VWR_EXTRA_SETTERS) + void set_x (const scalar_type& v) { x() = v; } + void set_y (const scalar_type& v) { y() = v; } +#endif + #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)); } @@ -198,6 +216,10 @@ namespace vwr { typedef typename VectorWrapperInfo::scalar_type scalar_type; scalar_type& x ( void ); const scalar_type& x ( void ) const; + +#if defined(VWR_EXTRA_SETTERS) + void set_x (const scalar_type& v) { x() = v; } +#endif }; template