mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-18 06:42:13 +02:00
Adding simple compile time tests
[SVN r49409]
This commit is contained in:
24
test/compile_time/Makefile
Normal file
24
test/compile_time/Makefile
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#=============================================================================
|
||||||
|
# Copyright (c) 2008 Dan Marsden
|
||||||
|
#
|
||||||
|
# Use modification and distribution are subject to the Boost Software
|
||||||
|
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
# http://www.boost.org/LICENSE_1_0.txt).
|
||||||
|
#==============================================================================
|
||||||
|
|
||||||
|
CXX=g++
|
||||||
|
CXXFLAGS=-I$(BOOST_ROOT)
|
||||||
|
|
||||||
|
all: vector_construction vector_iteration vector_intrinsic
|
||||||
|
|
||||||
|
vector_construction: vector_construction.cpp
|
||||||
|
time $(CXX) $(CXXFLAGS) vector_construction.cpp -o vector_construction
|
||||||
|
|
||||||
|
vector_iteration: vector_iteration.cpp
|
||||||
|
time $(CXX) $(CXXFLAGS) vector_iteration.cpp -o vector_iteration
|
||||||
|
|
||||||
|
vector_intrinsic: vector_intrinsic.cpp
|
||||||
|
time $(CXX) $(CXXFLAGS) vector_intrinsic.cpp -o vector_intrinsic
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f vector_construction vector_construction.o vector_iteration vector_iteration.o vector_intrinsic vector_intrinsic.o
|
75
test/compile_time/driver.hpp
Normal file
75
test/compile_time/driver.hpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2008 Dan Marsden
|
||||||
|
|
||||||
|
Use modification and distribution are subject to the Boost Software
|
||||||
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt).
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#if !defined(BOOST_FUSION_COMPILE_TIME_DRIVER)
|
||||||
|
#define BOOST_FUSION_COMPILE_TIME_DRIVER
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<0>();
|
||||||
|
test<1>();
|
||||||
|
test<2>();
|
||||||
|
test<3>();
|
||||||
|
test<4>();
|
||||||
|
|
||||||
|
test<5>();
|
||||||
|
test<6>();
|
||||||
|
test<7>();
|
||||||
|
test<8>();
|
||||||
|
test<9>();
|
||||||
|
|
||||||
|
test<10>();
|
||||||
|
test<11>();
|
||||||
|
test<12>();
|
||||||
|
test<13>();
|
||||||
|
test<14>();
|
||||||
|
|
||||||
|
test<15>();
|
||||||
|
test<16>();
|
||||||
|
test<17>();
|
||||||
|
test<18>();
|
||||||
|
test<19>();
|
||||||
|
|
||||||
|
test<20>();
|
||||||
|
test<21>();
|
||||||
|
test<22>();
|
||||||
|
test<23>();
|
||||||
|
test<24>();
|
||||||
|
|
||||||
|
test<25>();
|
||||||
|
test<26>();
|
||||||
|
test<27>();
|
||||||
|
test<28>();
|
||||||
|
test<29>();
|
||||||
|
|
||||||
|
test<30>();
|
||||||
|
test<31>();
|
||||||
|
test<32>();
|
||||||
|
test<33>();
|
||||||
|
test<34>();
|
||||||
|
|
||||||
|
test<35>();
|
||||||
|
test<36>();
|
||||||
|
test<37>();
|
||||||
|
test<38>();
|
||||||
|
test<39>();
|
||||||
|
|
||||||
|
test<40>();
|
||||||
|
test<41>();
|
||||||
|
test<42>();
|
||||||
|
test<43>();
|
||||||
|
test<44>();
|
||||||
|
|
||||||
|
test<45>();
|
||||||
|
test<46>();
|
||||||
|
test<47>();
|
||||||
|
test<48>();
|
||||||
|
test<49>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
28
test/compile_time/vector_construction.cpp
Normal file
28
test/compile_time/vector_construction.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2008 Dan Marsden
|
||||||
|
|
||||||
|
Use modification and distribution are subject to the Boost Software
|
||||||
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt).
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
|
||||||
|
namespace fusion = boost::fusion;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template<int n, int batch>
|
||||||
|
struct distinct
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<int batch>
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
fusion::vector<
|
||||||
|
distinct<0, batch>, distinct<1, batch>, distinct<2, batch>, distinct<3, batch>, distinct<4, batch>,
|
||||||
|
distinct<5, batch>, distinct<6, batch>, distinct<7, batch>, distinct<8, batch>, distinct<9, batch> > v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "./driver.hpp"
|
59
test/compile_time/vector_intrinsic.cpp
Normal file
59
test/compile_time/vector_intrinsic.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2008 Dan Marsden
|
||||||
|
|
||||||
|
Use modification and distribution are subject to the Boost Software
|
||||||
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt).
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
#include <boost/fusion/include/intrinsic.hpp>
|
||||||
|
|
||||||
|
namespace fusion = boost::fusion;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template<int n, int batch>
|
||||||
|
struct distinct
|
||||||
|
{};
|
||||||
|
|
||||||
|
template<int batch>
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
typedef fusion::vector<
|
||||||
|
distinct<0, batch>, distinct<1, batch>, distinct<2, batch>, distinct<3, batch>, distinct<4, batch>,
|
||||||
|
distinct<5, batch>, distinct<6, batch>, distinct<7, batch>, distinct<8, batch>, distinct<9, batch> > v_type;
|
||||||
|
|
||||||
|
v_type v;
|
||||||
|
|
||||||
|
fusion::at_c<0>(v);
|
||||||
|
fusion::at_c<1>(v);
|
||||||
|
fusion::at_c<2>(v);
|
||||||
|
fusion::at_c<3>(v);
|
||||||
|
fusion::at_c<4>(v);
|
||||||
|
|
||||||
|
fusion::at_c<5>(v);
|
||||||
|
fusion::at_c<6>(v);
|
||||||
|
fusion::at_c<7>(v);
|
||||||
|
fusion::at_c<8>(v);
|
||||||
|
fusion::at_c<9>(v);
|
||||||
|
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 0>::type va0;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 1>::type va1;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 2>::type va2;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 3>::type va3;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 4>::type va4;
|
||||||
|
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 5>::type va5;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 6>::type va6;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 7>::type va7;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 8>::type va8;
|
||||||
|
typedef typename fusion::result_of::value_at_c<v_type, 9>::type va9;
|
||||||
|
|
||||||
|
fusion::begin(v);
|
||||||
|
fusion::end(v);
|
||||||
|
fusion::size(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "./driver.hpp"
|
38
test/compile_time/vector_iteration.cpp
Normal file
38
test/compile_time/vector_iteration.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*=============================================================================
|
||||||
|
Copyright (c) 2008 Dan Marsden
|
||||||
|
|
||||||
|
Use modification and distribution are subject to the Boost Software
|
||||||
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
http://www.boost.org/LICENSE_1_0.txt).
|
||||||
|
==============================================================================*/
|
||||||
|
|
||||||
|
#include <boost/fusion/include/vector.hpp>
|
||||||
|
#include <boost/fusion/include/for_each.hpp>
|
||||||
|
|
||||||
|
namespace fusion = boost::fusion;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
template<int n, int batch>
|
||||||
|
struct distinct
|
||||||
|
{};
|
||||||
|
|
||||||
|
struct null_op
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void operator()(T const& t) const
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int batch>
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
fusion::vector<
|
||||||
|
distinct<0, batch>, distinct<1, batch>, distinct<2, batch>, distinct<3, batch>, distinct<4, batch>,
|
||||||
|
distinct<5, batch>, distinct<6, batch>, distinct<7, batch>, distinct<8, batch>, distinct<9, batch> > v;
|
||||||
|
|
||||||
|
fusion::for_each(v, null_op());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "./driver.hpp"
|
Reference in New Issue
Block a user