Browse Source

*: added error messages to static asserts

Michele Caini 5 years ago
parent
commit
bedea4b11a
2 changed files with 11 additions and 11 deletions
  1. 10 10
      src/entt/entity/handle.hpp
  2. 1 1
      src/entt/poly/poly.hpp

+ 10 - 10
src/entt/entity/handle.hpp

@@ -140,7 +140,7 @@ struct basic_handle {
      */
     template<typename Component, typename... Args>
     decltype(auto) emplace(Args &&... args) const {
-        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
+        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>), "Invalid type");
         return reg->template emplace<Component>(entt, std::forward<Args>(args)...);
     }
 
@@ -154,7 +154,7 @@ struct basic_handle {
      */
     template<typename Component, typename... Args>
     decltype(auto) emplace_or_replace(Args &&... args) const {
-        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
+        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>), "Invalid type");
         return reg->template emplace_or_replace<Component>(entt, std::forward<Args>(args)...);
     }
 
@@ -168,7 +168,7 @@ struct basic_handle {
      */
     template<typename Component, typename... Func>
     decltype(auto) patch(Func &&... func) const {
-        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
+        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>), "Invalid type");
         return reg->template patch<Component>(entt, std::forward<Func>(func)...);
     }
 
@@ -182,7 +182,7 @@ struct basic_handle {
      */
     template<typename Component, typename... Args>
     decltype(auto) replace(Args &&... args) const {
-        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
+        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>), "Invalid type");
         return reg->template replace<Component>(entt, std::forward<Args>(args)...);
     }
 
@@ -193,7 +193,7 @@ struct basic_handle {
      */
     template<typename... Component>
     void remove() const {
-        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...));
+        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...), "Invalid type");
         reg->template remove<Component...>(entt);
     }
 
@@ -205,7 +205,7 @@ struct basic_handle {
      */
     template<typename... Component>
     decltype(auto) remove_if_exists() const {
-        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...));
+        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...), "Invalid type");
         return reg->template remove_if_exists<Component...>(entt);
     }
 
@@ -214,7 +214,7 @@ struct basic_handle {
      * @sa basic_registry::remove_all
      */
     void remove_all() const {
-        static_assert(sizeof...(Type) == 0);
+        static_assert(sizeof...(Type) == 0, "Invalid operation");
         reg->remove_all(entt);
     }
 
@@ -249,7 +249,7 @@ struct basic_handle {
      */
     template<typename... Component>
     [[nodiscard]] decltype(auto) get() const {
-        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...));
+        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...), "Invalid type");
         return reg->template get<Component...>(entt);
     }
 
@@ -263,7 +263,7 @@ struct basic_handle {
      */
     template<typename Component, typename... Args>
     [[nodiscard]] decltype(auto) get_or_emplace(Args &&... args) const {
-        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
+        static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>), "Invalid type");
         return reg->template get_or_emplace<Component>(entt, std::forward<Args>(args)...);
     }
 
@@ -275,7 +275,7 @@ struct basic_handle {
      */
     template<typename... Component>
     [[nodiscard]] auto try_get() const {
-        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...));
+        static_assert(sizeof...(Type) == 0 || (type_list_contains_v<type_list<Type...>, Component> && ...), "Invalid type");
         return reg->template try_get<Component...>(entt);
     }
 

+ 1 - 1
src/entt/poly/poly.hpp

@@ -105,7 +105,7 @@ public:
      */
     template<typename Type>
     [[nodiscard]] static const auto * instance() {
-        static_assert(std::is_same_v<Type, std::decay_t<Type>>);
+        static_assert(std::is_same_v<Type, std::decay_t<Type>>, "Type differs from its decayed form");
         static const auto vtable = fill_vtable<Type>(std::make_index_sequence<Concept::template impl<Type>::size>{});
         return &vtable;
     }