diff --git a/doc/tuple_users_guide.html b/doc/tuple_users_guide.html index 65e3a04..5f53a81 100644 --- a/doc/tuple_users_guide.html +++ b/doc/tuple_users_guide.html @@ -74,22 +74,14 @@ Both tuple_io.hpp and tuple_comparison.hpp include CopyConstructible [C++ Standard 20.1.3]. (To be precise, CopyConstrucible is an unnecessary strong requirement for a valid element type, as the operator& is not used by the library.) -

- -

-Examples of types that are not allowed as tuple elements: - -

- -Note that a reference to any of these non-copyable types is a valid element -type. +The data element can be any C++ type. +Note that void and plain function types are valid +C++ types, but objects of such types cannot exist. +Hence, if a tuple type contains such types as elements, the tuple type +can exist, but not an object of that type. +There are natural limitations for element types that cannot +be be copied, or that are not default constructible (see 'Constructing tuples' + below).

For example, the following definitions are valid tuple instantiations (A, B and C are some user defined classes): @@ -101,21 +93,6 @@ tuple<std::string, std::pair<A, B> > tuple<A*, tuple<const A*, const B&, C>, bool, void*> -

-The following code shows some invalid tuple instantiations: -

class Y { 
-  Y(const Y&); 
-public:
-  Y();
-};
-
-tuple<Y>        // not allowed, objects of type Y cannot be copied
-tuple<char[10]> // not allowed: arrays cannot be copied
-
- -Note however that tuple<Y&> and tuple<char(&)[10]> are valid instantiations. - -

Constructing tuples

@@ -156,6 +133,31 @@ tuple<const double&>(d+3.14) // ok, but dangerous: // the element becomes a dangling reference +

Using an initial value for an element that cannot be copied, is a compile +time error: + +

class Y { 
+  Y(const Y&); 
+public:
+  Y();
+};
+
+char a[10];
+
+tuple<char[10], Y>(a, Y()); // error, neither arrays nor Y can be copied
+tuple<char[10], Y>();       // ok
+
+ +Note particularly that the following is perfectly ok: +
Y y;
+tuple<char(&)[10], Y&>(a, y); 
+
+ +It is possible to come up with a tuple type that cannot be constructed. +This occurs if an element that cannot be initialized has a lower +index than an element that requires initialization. +For example: tuple<char[10], int&>. +

In sum, the tuple construction is semantically just a group of individual elementary constructions.