forked from boostorg/tuple
element<T>::type takes constness into consideration
[SVN r17666]
This commit is contained in:
@ -20,7 +20,9 @@ Suppose <code>T</code> is a tuple type, and <code>N</code> is a constant integra
|
|||||||
|
|
||||||
<code><pre>element<N, T>::type</pre></code>
|
<code><pre>element<N, T>::type</pre></code>
|
||||||
|
|
||||||
gives the type of the <code>N</code>th element in the tuple type <code>T</code>.
|
gives the type of the <code>N</code>th element in the tuple type <code>T</code>. If <code>T</code> is const, the resulting type is const qualified as well.
|
||||||
|
Note that the constness of <code>T</code> does not affect reference type
|
||||||
|
elements.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<code><pre>length<T>::value</pre></code>
|
<code><pre>length<T>::value</pre></code>
|
||||||
|
@ -153,6 +153,21 @@ struct element<0,T>
|
|||||||
typedef typename T::head_type type;
|
typedef typename T::head_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<int N, class T>
|
||||||
|
struct element<N, const T>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
typedef typename T::tail_type Next;
|
||||||
|
typedef typename element<N-1, Next>::type unqualified_type;
|
||||||
|
public:
|
||||||
|
typedef typename boost::add_const<unqualified_type>::type type;
|
||||||
|
};
|
||||||
|
template<class T>
|
||||||
|
struct element<0,const T>
|
||||||
|
{
|
||||||
|
typedef typename boost::add_const<typename T::head_type>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
// -get function templates -----------------------------------------------
|
// -get function templates -----------------------------------------------
|
||||||
// Usage: get<N>(aTuple)
|
// Usage: get<N>(aTuple)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user