Skip to content

Commit

Permalink
Added C++17 checks to ensure that vpRGBa and vpRGBf are trivially cop…
Browse files Browse the repository at this point in the history
…yable/assignable
  • Loading branch information
SamFlt committed Sep 19, 2024
1 parent 25635f9 commit 635acf8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
12 changes: 12 additions & 0 deletions modules/core/include/visp3/core/vpRGBa.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpColVector.h>

#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
#include <type_traits>
#endif


BEGIN_VISP_NAMESPACE
/*!
\class vpRGBa
Expand Down Expand Up @@ -171,5 +176,12 @@ class VISP_EXPORT vpRGBa

friend VISP_EXPORT vpRGBa operator*(const double &x, const vpRGBa &rgb);
};

#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
static_assert(std::is_trivially_assignable_v<vpRGBa, vpRGBa>);
static_assert(std::is_trivially_copyable_v<vpRGBa>);
#endif


END_VISP_NAMESPACE
#endif
16 changes: 15 additions & 1 deletion modules/core/include/visp3/core/vpRGBf.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
#include <visp3/core/vpConfig.h>
#include <visp3/core/vpColVector.h>

#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_17)
#include <type_traits>
#endif

BEGIN_VISP_NAMESPACE

/*!
Expand Down Expand Up @@ -103,7 +107,7 @@ class VISP_EXPORT vpRGBf
/*!
Copy constructor.
*/
inline vpRGBf(const vpRGBf &v) : R(v.R), G(v.G), B(v.B) { }
inline vpRGBf(const vpRGBf &v) = default;

/*!
Create a RGB value from a 3 dimensional column vector.
Expand Down Expand Up @@ -144,5 +148,15 @@ class VISP_EXPORT vpRGBf
friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb);
friend VISP_EXPORT vpRGBf operator*(float x, const vpRGBf &rgb);
};

#if (VISP_CXX_STANDARD > VISP_CXX_STANDARD_98)
static_assert(std::is_trivially_assignable_v<vpRGBf, vpRGBf>);
static_assert(std::is_trivially_copyable_v<vpRGBf>);
#endif


END_VISP_NAMESPACE



#endif

0 comments on commit 635acf8

Please sign in to comment.