mirror of https://github.com/CGAL/cgal
add helper functions tuple_size and tuple_element for CGAL::cpp0x:tuple
This is defined in cpp0x and tr1 but not in boost: in case boost::tuple is used, it relies on internal boost struct.
This commit is contained in:
parent
34813708ac
commit
54b0fbc99a
|
|
@ -42,16 +42,29 @@ using std::tuple;
|
|||
using std::make_tuple;
|
||||
using std::tie;
|
||||
using std::get;
|
||||
using std::tuple_size;
|
||||
using std::tuple_element;
|
||||
#elif !defined CGAL_CFG_NO_TR1_TUPLE
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::make_tuple;
|
||||
using std::tr1::tie;
|
||||
using std::tr1::get;
|
||||
using std::tr1::tuple_size;
|
||||
using std::tr1::tuple_element;
|
||||
#else
|
||||
using boost::tuple;
|
||||
using boost::make_tuple;
|
||||
using boost::tie;
|
||||
using boost::get;
|
||||
|
||||
//tuple_size
|
||||
template <class T>
|
||||
struct tuple_size:public boost::tuples::length<T> {};
|
||||
|
||||
//tuple_element
|
||||
template <int N,class T>
|
||||
struct tuple_element: public boost::tuples::element<N,T>{};
|
||||
|
||||
#endif
|
||||
|
||||
} // cpp0x
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include <CGAL/Circulator_project.h>
|
||||
#include <CGAL/Circulator_on_node.h>
|
||||
#include <CGAL/function_objects.h>
|
||||
#include <CGAL/tuple.h>
|
||||
|
||||
using namespace CGAL;
|
||||
|
||||
|
|
@ -8987,6 +8988,24 @@ void test_Quadruple()
|
|||
if (x2 == y2) x4.third = x3;
|
||||
}
|
||||
|
||||
void test_tuple(){
|
||||
typedef CGAL::cpp0x::tuple<> T0;
|
||||
typedef CGAL::cpp0x::tuple<int,int> T1;
|
||||
typedef CGAL::cpp0x::tuple<int,My_to_int,int,int> T2;
|
||||
|
||||
|
||||
BOOST_STATIC_ASSERT( CGAL::cpp0x::tuple_size<T0>::value == 0 );
|
||||
BOOST_STATIC_ASSERT( CGAL::cpp0x::tuple_size<T1>::value == 2 );
|
||||
BOOST_STATIC_ASSERT( CGAL::cpp0x::tuple_size<T2>::value == 4 );
|
||||
BOOST_STATIC_ASSERT( (boost::is_same<CGAL::cpp0x::tuple_element<1,T2>::type,My_to_int>::value) );
|
||||
|
||||
T1 t1=CGAL::cpp0x::make_tuple(1,2);
|
||||
int i1=-1,i2=-1;
|
||||
CGAL::cpp0x::tie(i1,i2)=t1;
|
||||
CGAL_assertion( CGAL::cpp0x::get<0>(t1)==i1 );
|
||||
CGAL_assertion( CGAL::cpp0x::get<1>(t1)==i2 );
|
||||
}
|
||||
|
||||
void test_predecessor_successor()
|
||||
{
|
||||
std::vector<int> V;
|
||||
|
|
@ -9018,6 +9037,7 @@ int main() {
|
|||
test_Quadruple();
|
||||
test_predecessor_successor();
|
||||
clean_global_data();
|
||||
test_tuple();
|
||||
return 0;
|
||||
}
|
||||
// EOF //
|
||||
|
|
|
|||
Loading…
Reference in New Issue