From a85db038be618a313df68e1df3ac33c3c6061685 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Tue, 22 Jan 2019 11:12:50 +0100 Subject: [PATCH] Fix usage of is_trivially_copyable on older GCC (for real this time) --- src/libslic3r/Fill/FillBase.hpp | 7 ++----- src/libslic3r/Slicing.hpp | 3 ++- src/libslic3r/Utils.hpp | 10 ++++++++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/Fill/FillBase.hpp b/src/libslic3r/Fill/FillBase.hpp index d43ac8b44b..8bf6c36898 100644 --- a/src/libslic3r/Fill/FillBase.hpp +++ b/src/libslic3r/Fill/FillBase.hpp @@ -11,6 +11,7 @@ #include "../libslic3r.h" #include "../BoundingBox.hpp" #include "../PrintConfig.hpp" +#include "../Utils.hpp" namespace Slic3r { @@ -40,11 +41,7 @@ struct FillParams // in this case we don't try to make more continuous paths bool complete; }; -#if (!defined __GNUC__) || __GNUC__ > 4 -// Older GCCs don't have std::is_trivially_copyable -// cf. https://gcc.gnu.org/onlinedocs/gcc-4.9.4/libstdc++/manual/manual/status.html#status.iso.2011 -static_assert(std::is_trivially_copyable::value, "FillParams class is not POD (and it should be - see constructor)."); -#endif +static_assert(IsTriviallyCopyable::value, "FillParams class is not POD (and it should be - see constructor)."); class Fill { diff --git a/src/libslic3r/Slicing.hpp b/src/libslic3r/Slicing.hpp index 028605fd5d..0945278503 100644 --- a/src/libslic3r/Slicing.hpp +++ b/src/libslic3r/Slicing.hpp @@ -10,6 +10,7 @@ #include #include "libslic3r.h" +#include "Utils.hpp" namespace Slic3r { @@ -93,7 +94,7 @@ struct SlicingParameters coordf_t object_print_z_min; coordf_t object_print_z_max; }; -static_assert(std::is_trivially_copyable::value, "SlicingParameters class is not POD (and it should be - see constructor)."); +static_assert(IsTriviallyCopyable::value, "SlicingParameters class is not POD (and it should be - see constructor)."); // The two slicing parameters lead to the same layering as long as the variable layer thickness is not in action. diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index cfae9edd1a..ed12d05594 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -159,6 +159,16 @@ template size_t next_highest_power_of_2(T v, extern std::string xml_escape(std::string text); +#if defined __GNUC__ & __GNUC__ < 5 +// Older GCCs don't have std::is_trivially_copyable +// cf. https://gcc.gnu.org/onlinedocs/gcc-4.9.4/libstdc++/manual/manual/status.html#status.iso.2011 +#warning "GCC version < 5, faking std::is_trivially_copyable" +template struct IsTriviallyCopyable { static constexpr bool value = true; }; +#else +template struct IsTriviallyCopyable : public std::is_trivially_copyable {}; +#endif + + class ScopeGuard { public: