forked from boostorg/tuple
included rich_cons
[SVN r11015]
This commit is contained in:
@ -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<T>::type f() { return T(); }
|
||||
};
|
||||
|
||||
// This is just to produce a more informative error message
|
||||
// The code would fail in any case
|
||||
template<class T, int N>
|
||||
struct default_arg<T[N]> {
|
||||
static T* f() {
|
||||
return generate_error<T[N]>::arrays_are_not_valid_tuple_elements; }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct default_arg<T&> {
|
||||
@ -235,6 +246,12 @@ struct cons {
|
||||
typename tuple_access_traits<tail_type>::const_type
|
||||
get_tail() const { return tail; }
|
||||
|
||||
cons() : head(detail::tuples::default_arg<HT>::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<head_type>::parameter_type h,
|
||||
const tail_type& t)
|
||||
: head (h), tail(t) {}
|
||||
@ -302,7 +319,9 @@ struct cons<HT, null_type> {
|
||||
get_head() const { return head; }
|
||||
|
||||
const null_type get_tail() const { return null_type(); }
|
||||
|
||||
|
||||
cons() : head(detail::tuples::default_arg<HT>::f()) {}
|
||||
|
||||
cons(typename tuple_access_traits<head_type>::parameter_type h,
|
||||
const null_type& = null_type())
|
||||
: head (h) {}
|
||||
|
Reference in New Issue
Block a user