diff --git a/include/boost/type_traits/function_traits.hpp b/include/boost/type_traits/function_traits.hpp
index 86bce3e..2ec084b 100644
--- a/include/boost/type_traits/function_traits.hpp
+++ b/include/boost/type_traits/function_traits.hpp
@@ -300,6 +300,66 @@ struct function_traits :
{
};
+#else
+
+namespace detail {
+
+template
+struct type_of_size
+{
+ char elements[N];
+};
+
+template
+type_of_size<1> function_arity_helper(R (*f)());
+
+template
+type_of_size<2> function_arity_helper(R (*f)(T1));
+
+template
+type_of_size<3> function_arity_helper(R (*f)(T1, T2));
+
+template
+type_of_size<4> function_arity_helper(R (*f)(T1, T2, T3));
+
+template
+type_of_size<5> function_arity_helper(R (*f)(T1, T2, T3, T4));
+
+template
+type_of_size<6> function_arity_helper(R (*f)(T1, T2, T3, T4, T5));
+
+template
+type_of_size<7> function_arity_helper(R (*f)(T1, T2, T3, T4, T5, T6));
+
+template
+type_of_size<8> function_arity_helper(R (*f)(T1, T2, T3, T4, T5, T6, T7));
+
+template
+type_of_size<9> function_arity_helper(R (*f)(T1, T2, T3, T4, T5, T6, T7, T8));
+
+template
+type_of_size<10> function_arity_helper(R (*f)(T1, T2, T3, T4, T5, T6, T7, T8,
+ T9));
+
+template
+type_of_size<11> function_arity_helper(R (*f)(T1, T2, T3, T4, T5, T6, T7, T8,
+ T9, T10));
+} // end namespace detail
+
+// Won't work with references
+template
+struct function_traits
+{
+ BOOST_STATIC_CONSTANT(int, arity = (sizeof(detail::function_arity_helper((Function*)0))-1));
+};
+
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
} // boost
diff --git a/index.htm b/index.htm
index 913cbb9..51b2951 100644
--- a/index.htm
+++ b/index.htm
@@ -839,7 +839,7 @@ properties.
::boost::function_traits<F>::arity |
Determine the arity of the function type F . |
|
- P |
+ Without partial specialisation support, this template does not compile for reference types. |
|
@@ -975,6 +975,13 @@ template.
<boost/type_traits/object_traits.hpp> |
|
+
+ |
+ function_traits |
+ <boost/type_traits/function_traits.hpp> |
+ |
+
+
|
has_trivial_constructor |
diff --git a/tests/function_traits_test.cpp b/tests/function_traits_test.cpp
index 0c4655e..0e30f86 100644
--- a/tests/function_traits_test.cpp
+++ b/tests/function_traits_test.cpp
@@ -45,11 +45,13 @@ struct is_double
int test_main(int, char*[])
{
-#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef int F2(float, double);
typedef boost::function_traits traits;
+ BOOST_TEST(traits::arity == 2);
+
+#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
BOOST_TEST(is_int::value);
BOOST_TEST(is_float::value);
BOOST_TEST(is_double::value);