diff --git a/include/boost/tuple/detail/tuple_basic.hpp b/include/boost/tuple/detail/tuple_basic.hpp index 5094a87..5165927 100644 --- a/include/boost/tuple/detail/tuple_basic.hpp +++ b/include/boost/tuple/detail/tuple_basic.hpp @@ -22,6 +22,9 @@ // William Kempf, Vesa Karvonen, John Max Skaller, Ed Brey, Beman Davis, // David Abrahams. +// Revision history: +// 2001 08 30 David Abrahams +// Added default constructor for cons<>. // ----------------------------------------------------------------- #ifndef BOOST_TUPLE_BASIC_HPP @@ -79,6 +82,14 @@ struct default_arg { // from all temporaries. static typename boost::remove_cv::type f() { return T(); } }; + +// This is just to produce a more informative error message +// The code would fail in any case +template +struct default_arg { + static T* f() { + return generate_error::arrays_are_not_valid_tuple_elements; } +}; template struct default_arg { @@ -235,6 +246,12 @@ struct cons { typename tuple_access_traits::const_type get_tail() const { return tail; } + cons() : head(detail::tuples::default_arg::f()), tail() {} + // the argument for head is not strictly needed, but it prevents + // array type elements. This is good, since array type elements + // cannot be supported properly in any case (no assignment, + // copy works only if the tails are exactly the same type, ...) + cons(typename tuple_access_traits::parameter_type h, const tail_type& t) : head (h), tail(t) {} @@ -302,7 +319,9 @@ struct cons { get_head() const { return head; } const null_type get_tail() const { return null_type(); } - + + cons() : head(detail::tuples::default_arg::f()) {} + cons(typename tuple_access_traits::parameter_type h, const null_type& = null_type()) : head (h) {}