diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..affc40e1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,23 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + fusion +) + +# Add a library target to the build system +boost_library_project( + fusion + # SRCDIRS + # TESTDIRS + HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "Library for working with tuples, including various containers, algorithms, etc." + MODULARIZED + AUTHORS "Joel de Guzman " + "Dan Marsden " + "Tobias Schwinger " + # MAINTAINERS +) + + diff --git a/test/compile_time/Makefile b/test/compile_time/Makefile index fdbd1bb4..4887cf24 100644 --- a/test/compile_time/Makefile +++ b/test/compile_time/Makefile @@ -9,16 +9,21 @@ CXX=g++ CXXFLAGS=-I$(BOOST_ROOT) -all: vector_construction vector_iteration vector_intrinsic +TEST_SRCS=\ + vector_construction.cpp\ + vector_iteration.cpp\ + vector_intrinsic.cpp\ + fold.cpp\ + transform.cpp -vector_construction: vector_construction.cpp - time $(CXX) $(CXXFLAGS) vector_construction.cpp -o vector_construction +TEST_OBJS=$(TEST_SRCS:.cpp=.o) -vector_iteration: vector_iteration.cpp - time $(CXX) $(CXXFLAGS) vector_iteration.cpp -o vector_iteration +TEST_TARGETS=$(TEST_SRCS:.cpp=.test) -vector_intrinsic: vector_intrinsic.cpp - time $(CXX) $(CXXFLAGS) vector_intrinsic.cpp -o vector_intrinsic +all: $(TEST_TARGETS) + +%.test : %.cpp + time $(CXX) $(CXXFLAGS) $< -o $@ clean: - rm -f vector_construction vector_construction.o vector_iteration vector_iteration.o vector_intrinsic vector_intrinsic.o + rm -f $(TEST_TARGETS) $(TEST_OBJS) diff --git a/test/compile_time/fold.cpp b/test/compile_time/fold.cpp new file mode 100644 index 00000000..fa2e8f6c --- /dev/null +++ b/test/compile_time/fold.cpp @@ -0,0 +1,42 @@ +/*============================================================================= + 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 +#include + +namespace fusion = boost::fusion; + +namespace +{ + template + struct distinct + {}; + + struct f + { + typedef int result_type; + + template + int operator()(distinct const& d, int state) const + { + return state + n; + } + }; + + template + 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::fold(v, 0, f()); + } +} + +#include "./driver.hpp" diff --git a/test/compile_time/transform.cpp b/test/compile_time/transform.cpp new file mode 100644 index 00000000..04ad8ab2 --- /dev/null +++ b/test/compile_time/transform.cpp @@ -0,0 +1,55 @@ +/*============================================================================= + 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 +#include +#include + +namespace fusion = boost::fusion; + +namespace +{ + template + struct distinct + { + static const int value = n; + }; + + struct f + { + typedef int result_type; + + template + result_type operator()(T const& t) const + { + return T::value; + } + }; + + struct touch + { + template + void operator()(T const&) const + {} + }; + + template + 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; + + // We're testing transform really + // for_each call is to force iteration through the lazy + // transform, otherwise very little will happen. + fusion::for_each(fusion::transform(v, f()), touch()); + } +} + +#include "./driver.hpp"