[glibmm: 1/3] Glib: Adding static check for template parameter



commit e1d1f6d99e882be0e28e86860cd73a8edb846770
Author: Pavlo Solntsev <p sun fun gmail com>
Date:   Sun Nov 17 23:04:05 2019 -0600

    Glib: Adding static check for template parameter
    
    To meet requirements for the passed type, compile
    type check for the passed type was added.

 glib/glibmm/value_custom.h | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/glib/glibmm/value_custom.h b/glib/glibmm/value_custom.h
index e5c19895..a59aaf31 100644
--- a/glib/glibmm/value_custom.h
+++ b/glib/glibmm/value_custom.h
@@ -26,6 +26,7 @@
 #include <glibmmconfig.h>
 #include <new>
 #include <typeinfo>
+#include <type_traits>
 
 namespace Glib
 {
@@ -98,6 +99,15 @@ private:
 template <class T, typename Enable = void>
 class Value : public ValueBase_Boxed
 {
+  static_assert(std::is_default_constructible<T>(), "T should be default constractable");
+  static_assert(std::is_copy_constructible<T>(), "T should be copy constractable");
+  static_assert(std::is_assignable<T&, T>(), "T should be assignable");
+  static_assert(std::is_assignable<T&, T&>(), "T should be assignable");
+  static_assert(std::is_assignable<T&, const T&>(), "T should be assignable");
+  static_assert(std::is_destructible<T>(), "T should be destructable");
+  static_assert(std::is_move_assignable<T>(), "T should be move assignable");
+  static_assert(std::is_move_constructible<T>(), "T should be move constractable");
+
 public:
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   // Used in class Glib::Traits::ValueCompatibleWithWrapProperty.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]