mirror of
https://github.com/boostorg/tuple.git
synced 2025-07-29 20:27:17 +02:00
Added forwarding get functions to solve problems with using::tuples::get statement.
[SVN r12290]
This commit is contained in:
@ -37,7 +37,50 @@ namespace boost {
|
||||
using tuples::tuple;
|
||||
using tuples::make_tuple;
|
||||
using tuples::tie;
|
||||
#if !defined(BOOST_NO_USING_TEMPLATE)
|
||||
using tuples::get;
|
||||
#elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
//
|
||||
// The "using tuples::get" statement causes the
|
||||
// Borland compiler to ICE, use forwarding
|
||||
// functions instead:
|
||||
//
|
||||
template<int N, class HT, class TT>
|
||||
inline typename tuples::access_traits<
|
||||
typename tuples::element<N, tuples::cons<HT, TT> >::type
|
||||
>::non_const_type
|
||||
get(tuples::cons<HT, TT>& c) {
|
||||
return tuples::get<N,HT,TT>(c);
|
||||
}
|
||||
// get function for const cons-lists, returns a const reference to
|
||||
// the element. If the element is a reference, returns the reference
|
||||
// as such (that is, can return a non-const reference)
|
||||
template<int N, class HT, class TT>
|
||||
inline typename tuples::access_traits<
|
||||
typename tuples::element<N, tuples::cons<HT, TT> >::type
|
||||
>::const_type
|
||||
get(const tuples::cons<HT, TT>& c) {
|
||||
return tuples::get<N,HT,TT>(c);
|
||||
}
|
||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
//
|
||||
// MSVC, using declarations don't mix with templates well,
|
||||
// so use forwarding functions instead:
|
||||
//
|
||||
template<int N, typename Head, typename Tail>
|
||||
typename tuples::detail::element_ref<N, tuples::cons<Head, Tail> >::RET
|
||||
get(tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
|
||||
{
|
||||
return tuples::detail::get_class<N>::get(t);
|
||||
}
|
||||
|
||||
template<int N, typename Head, typename Tail>
|
||||
typename tuples::detail::element_const_ref<N, tuples::cons<Head, Tail> >::RET
|
||||
get(const tuples::cons<Head, Tail>& t, tuples::detail::workaround_holder<N>* = 0)
|
||||
{
|
||||
return tuples::detail::get_class<N>::get(t);
|
||||
}
|
||||
#endif // BOOST_NO_USING_TEMPLATE
|
||||
|
||||
} // end namespace boost
|
||||
|
||||
|
Reference in New Issue
Block a user