diff --git a/include/eigenpy/utils/traits.hpp b/include/eigenpy/utils/traits.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ce6b4fae5c8a8cd63defe1f622e299f56342e42
--- /dev/null
+++ b/include/eigenpy/utils/traits.hpp
@@ -0,0 +1,30 @@
+//
+// Copyright (c) 2024 INRIA
+//
+//
+#include <type_traits>
+
+#ifndef __eigenpy_utils_traits_hpp__
+#define __eigenpy_utils_traits_hpp__
+
+namespace eigenpy {
+
+namespace details {
+
+/// Trait to detect if T is a class or an union
+template <typename T>
+struct is_class_or_union
+    : std::integral_constant<bool, std::is_class<T>::value ||
+                                       std::is_union<T>::value> {};
+
+/// Trait to remove cvref and call is_class_or_union
+template <typename T>
+struct is_class_or_union_remove_cvref
+    : is_class_or_union<typename std::remove_cv<
+          typename std::remove_reference<T>::type>::type> {};
+
+}  // namespace details
+
+}  // namespace eigenpy
+
+#endif  // ifndef __eigenpy_utils_traits_hpp__
diff --git a/include/eigenpy/variant.hpp b/include/eigenpy/variant.hpp
index 4028f856bc721c56177e019963eccdd6cb950768..f989a0f9e8ea1befa65e1d5084dd03b252417188 100644
--- a/include/eigenpy/variant.hpp
+++ b/include/eigenpy/variant.hpp
@@ -6,6 +6,7 @@
 #define __eigenpy_utils_variant_hpp__
 
 #include "eigenpy/fwd.hpp"
+#include "eigenpy/utils/traits.hpp"
 
 #include <boost/python.hpp>
 #include <boost/variant.hpp>
@@ -204,18 +205,6 @@ struct VariantValueToObject : VariantVisitorType<PyObject*, Variant> {
   using Base::operator();
 };
 
-/// Trait to detect if T is a class or an union
-template <typename T>
-struct is_class_or_union
-    : std::integral_constant<bool, std::is_class<T>::value ||
-                                       std::is_union<T>::value> {};
-
-/// Trait to remove cvref and call is_class_or_union
-template <typename T>
-struct is_class_or_union_remove_cvref
-    : is_class_or_union<typename std::remove_cv<
-          typename std::remove_reference<T>::type>::type> {};
-
 /// Convert {boost,std}::variant<class...> alternative reference to a Python
 /// object. This converter return the alternative reference. The code that
 /// create the reference holder is taken from \see