diff options
Diffstat (limited to 'src/boost/libs/mpl')
225 files changed, 10070 insertions, 0 deletions
diff --git a/src/boost/libs/mpl/CMakeLists.txt b/src/boost/libs/mpl/CMakeLists.txt new file mode 100644 index 00000000..2d6020a3 --- /dev/null +++ b/src/boost/libs/mpl/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2018 Mike Dev +# Distributed under the Boost Software License, Version 1.0. +# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt +# +# NOTE: CMake support for Boost.Mpl is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required( VERSION 3.5 ) +project( BoostMpl LANGUAGES CXX ) + +add_library( boost_mpl INTERFACE ) +add_library( Boost::mpl ALIAS boost_mpl ) + +target_include_directories( boost_mpl INTERFACE include ) + +target_link_libraries( boost_mpl + INTERFACE + Boost::config + Boost::core + Boost::predef + Boost::preprocessor + Boost::static_assert + Boost::type_traits + Boost::utility +) + diff --git a/src/boost/libs/mpl/Jamfile b/src/boost/libs/mpl/Jamfile new file mode 100644 index 00000000..ba92b48d --- /dev/null +++ b/src/boost/libs/mpl/Jamfile @@ -0,0 +1,11 @@ +# Boost.MPL Library Jamfile +# +# Copyright (c) 2018 James E. King III +# +# 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) + +# please order by name to ease maintenance +build-project example ; +build-project test ; diff --git a/src/boost/libs/mpl/LICENSE b/src/boost/libs/mpl/LICENSE new file mode 100644 index 00000000..36b7cd93 --- /dev/null +++ b/src/boost/libs/mpl/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/boost/libs/mpl/README.md b/src/boost/libs/mpl/README.md new file mode 100644 index 00000000..b8806d4c --- /dev/null +++ b/src/boost/libs/mpl/README.md @@ -0,0 +1,34 @@ +MPL, part of collection of the [Boost C++ Libraries](http://github.com/boostorg), provides a general-purpose, high-level C++ template metaprogramming framework of compile-time algorithms, sequences and metafunctions. + +### License + +Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + +### Properties + +* C++03 +* Header Only + +### Build Status + +Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | +:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | +[`master`](https://github.com/boostorg/mpl/tree/master) | [![Build Status](https://travis-ci.org/boostorg/mpl.svg?branch=master)](https://travis-ci.org/boostorg/mpl) | [![Build status](https://ci.appveyor.com/api/projects/status/lx9pjj2ixqod6flb/branch/master?svg=true)](https://ci.appveyor.com/project/jeking3/mpl-nrhfm/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15866/badge.svg)](https://scan.coverity.com/projects/boostorg-mpl) | [![codecov](https://codecov.io/gh/boostorg/mpl/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/mpl/branch/master)| [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/mpl.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/mpl.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/mpl.html) +[`develop`](https://github.com/boostorg/mpl/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/mpl.svg?branch=develop)](https://travis-ci.org/boostorg/mpl) | [![Build status](https://ci.appveyor.com/api/projects/status/lx9pjj2ixqod6flb/branch/develop?svg=true)](https://ci.appveyor.com/project/jeking3/mpl-nrhfm/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/15866/badge.svg)](https://scan.coverity.com/projects/boostorg-mpl) | [![codecov](https://codecov.io/gh/boostorg/mpl/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/mpl/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/mpl.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/mpl.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/mpl.html) + +### Directories + +| Name | Purpose | +| ----------- | ------------------------------ | +| `doc` | documentation | +| `example` | examples | +| `include` | headers | +| `test` | unit tests | + +### More information + +* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-mpl) +* [Report bugs](https://github.com/boostorg/mpl/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. +* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). +* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[mpl]` tag at the beginning of the subject line. + diff --git a/src/boost/libs/mpl/book/chapter1/binary.hpp b/src/boost/libs/mpl/book/chapter1/binary.hpp new file mode 100644 index 00000000..39213863 --- /dev/null +++ b/src/boost/libs/mpl/book/chapter1/binary.hpp @@ -0,0 +1,18 @@ +// +// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed +// under 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/mpl/long.hpp" +#include "boost/mpl/alias.hpp" + +template< long n > struct binary + : mpl::long_< ( binary< n / 10 >::value << 1 ) + n % 10 > +{ +}; + +template<> struct binary<0> + : mpl::long_<0> +{ +}; diff --git a/src/boost/libs/mpl/example/Jamfile.v2 b/src/boost/libs/mpl/example/Jamfile.v2 new file mode 100644 index 00000000..ec2dc761 --- /dev/null +++ b/src/boost/libs/mpl/example/Jamfile.v2 @@ -0,0 +1,15 @@ +# Boost.MPL Library example Jamfile +# +# Copyright (c) 2008 James E. King III +# +# Distributed under the Boost Software License, Version 1.0. (See accompany- +# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +import testing ; + +test-suite "mpl-examples" + : [ run inherit_linearly.cpp ] + [ compile integer.cpp ] + [ run tuple_from_list.cpp ] + ; + diff --git a/src/boost/libs/mpl/example/fsm/README.txt b/src/boost/libs/mpl/example/fsm/README.txt new file mode 100644 index 00000000..0f4863fe --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/README.txt @@ -0,0 +1,28 @@ +What's In This Directory +======================== + +* player1.cpp - this is exactly what's covered in C++ Template + Metaprogramming (http://www.boost-consulting.com/mplbook); in fact, + it was auto-extracted from the examples as shown in the book. The + state machine framework and its use are together in one .cpp file; + normally they would be separated. You can think of the framework as + ending with the definition of the generate_dispatcher class + template. + + You can ignore the typedef called "dummy;" that was included in order to + test an intermediate example that appears in the book. + +* player2.cpp - this example demonstrates that the abstraction of the + framework is complete by replacing its implementation with one that + dispatches using O(1) table lookups, while still using the same code + to describe the particular FSM. Look at this one if you want to see + how to generate a static lookup table that's initialized at dynamic + initialization time. + +* player.cpp, state_machine.hpp - This example predates the book, and + is more sophisticated in some ways than what we cover in the other + examples. In particular, it supports state invariants, and it + maintains an internal event queue, which requires an additional + layer of runtime dispatching to sort out the next event to be + processed. + diff --git a/src/boost/libs/mpl/example/fsm/aux_/STT_impl_gen.hpp b/src/boost/libs/mpl/example/fsm/aux_/STT_impl_gen.hpp new file mode 100644 index 00000000..1fd0a5ff --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/aux_/STT_impl_gen.hpp @@ -0,0 +1,145 @@ + +#ifndef BOOST_FSM_HANDLER_INCLUDED +#define BOOST_FSM_HANDLER_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/if.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/front.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <typeinfo> +#include <cassert> + +namespace fsm { namespace aux { + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +template< typename Transition > +struct STT_void_row_impl +{ + typedef typename Transition::from_state_t state_t; + typedef typename Transition::fsm_t fsm_t; + typedef typename Transition::base_event_t base_event_t; + + static long do_process_event(fsm_t&, long state, base_event_t const&) + { + assert(false); + return state; + } + + static long do_transition(fsm_t&, long state, base_event_t const&) + { + assert(false); + return state; + } +}; + + +template< + typename PrevRowImpl + , typename Transition + > +struct STT_event_row_impl + : PrevRowImpl +{ + typedef typename Transition::from_state_t state_t; + typedef typename Transition::fsm_t fsm_t; + typedef typename Transition::base_event_t base_event_t; + + static long do_process_event(fsm_t& fsm, long state, base_event_t const& evt) + { + if (typeid(typename Transition::event_t) == typeid(evt)) + { + // typedefs are here to make GCC happy + typedef typename Transition::to_state_t to_state_; + typedef typename Transition::from_state_t from_state_; + + return Transition::do_transition(fsm, evt) + ? to_state_::do_check_invariant(fsm) + : from_state_::do_check_invariant(fsm) + ; + } + + return PrevRowImpl::do_process_event(fsm, state, evt); + } +}; + +template< + typename PrevRowImpl + , typename StateType + > +struct STT_state_row_impl + : PrevRowImpl +{ + typedef typename PrevRowImpl::fsm_t fsm_t; + typedef typename PrevRowImpl::base_event_t base_event_t; + + static long do_transition(fsm_t& fsm, long state, base_event_t const& evt) + { + return state == StateType::value + ? PrevRowImpl::do_process_event(fsm, state, evt) + : PrevRowImpl::do_transition(fsm, state, evt) + ; + } + + static long do_process_event(fsm_t&, long state, base_event_t const&) + { + assert(false); + return state; + } +}; + +template< + typename PrevRowImpl + , typename Transition + > +struct STT_row_impl +{ + typedef typename mpl::if_< + boost::is_same< + typename PrevRowImpl::state_t + , typename Transition::from_state_t + > + , STT_event_row_impl< PrevRowImpl,Transition > + , STT_event_row_impl< + STT_state_row_impl< PrevRowImpl,typename PrevRowImpl::state_t > + , Transition + > + >::type type; +}; + + +template< typename Transitions > +struct STT_impl_gen +{ + private: + typedef typename mpl::front<Transitions>::type first_; + typedef typename mpl::fold< + Transitions + , STT_void_row_impl<first_> + , STT_row_impl<_,_> + >::type STT_impl_; + + public: + typedef STT_state_row_impl< + STT_impl_ + , typename STT_impl_::state_t + > type; +}; + +}} + +#endif // BOOST_FSM_HANDLER_INCLUDED diff --git a/src/boost/libs/mpl/example/fsm/aux_/base_event.hpp b/src/boost/libs/mpl/example/fsm/aux_/base_event.hpp new file mode 100644 index 00000000..99df7d9d --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/aux_/base_event.hpp @@ -0,0 +1,59 @@ + +#ifndef BOOST_FSM_BASE_EVENT_INCLUDED +#define BOOST_FSM_BASE_EVENT_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <memory> +#include <boost/config.hpp> + +namespace fsm { namespace aux { + +// represent an abstract base for FSM events + +struct base_event +{ + public: + virtual ~base_event() {}; + +#if defined(BOOST_NO_CXX11_SMART_PTR) + + std::auto_ptr<base_event> clone() const + +#else + + std::unique_ptr<base_event> clone() const + +#endif + + { + return do_clone(); + } + + private: + +#if defined(BOOST_NO_CXX11_SMART_PTR) + + virtual std::auto_ptr<base_event> do_clone() const = 0; + +#else + + virtual std::unique_ptr<base_event> do_clone() const = 0; + +#endif + +}; + +}} + +#endif // BOOST_FSM_BASE_EVENT_INCLUDED diff --git a/src/boost/libs/mpl/example/fsm/aux_/event.hpp b/src/boost/libs/mpl/example/fsm/aux_/event.hpp new file mode 100644 index 00000000..895bd7a6 --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/aux_/event.hpp @@ -0,0 +1,54 @@ + +#ifndef BOOST_FSM_EVENT_INCLUDED +#define BOOST_FSM_EVENT_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include "base_event.hpp" + +namespace fsm { namespace aux { + +template< typename Derived > +struct event + : base_event +{ + public: + typedef base_event base_t; + + private: + +#if defined(BOOST_NO_CXX11_SMART_PTR) + + virtual std::auto_ptr<base_event> do_clone() const + { + return std::auto_ptr<base_event>( + new Derived(static_cast<Derived const&>(*this)) + ); + } + +#else + + virtual std::unique_ptr<base_event> do_clone() const + { + return std::unique_ptr<base_event>( + new Derived(static_cast<Derived const&>(*this)) + ); + } + +#endif + +}; + +}} + +#endif // BOOST_FSM_EVENT_INCLUDED diff --git a/src/boost/libs/mpl/example/fsm/aux_/state.hpp b/src/boost/libs/mpl/example/fsm/aux_/state.hpp new file mode 100644 index 00000000..bbe2bbf3 --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/aux_/state.hpp @@ -0,0 +1,42 @@ + +#ifndef BOOST_FSM_STATE_INCLUDED +#define BOOST_FSM_STATE_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/integral_c.hpp> + +namespace fsm { namespace aux { + +namespace mpl = boost::mpl; + +// represent a FSM state + +template< + typename T + , long State + , void (T::* invariant_func)() const + > +struct state + : mpl::integral_c<long,State> +{ + static long do_check_invariant(T const& x) + { + if (invariant_func) (x.*invariant_func)(); + return State; + } +}; + +}} + +#endif // BOOST_FSM_STATE_INCLUDED diff --git a/src/boost/libs/mpl/example/fsm/aux_/transition.hpp b/src/boost/libs/mpl/example/fsm/aux_/transition.hpp new file mode 100644 index 00000000..842e5e08 --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/aux_/transition.hpp @@ -0,0 +1,47 @@ + +#ifndef BOOST_FSM_TRANSITION_INCLUDED +#define BOOST_FSM_TRANSITION_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <cassert> + +namespace fsm { namespace aux { + +// represent a signle transition between states |From| and |To| + +template< + typename T + , typename From + , typename Event + , typename To + , bool (T::* transition_func)(Event const&) + > +struct transition +{ + typedef T fsm_t; + typedef From from_state_t; + typedef Event event_t; + typedef To to_state_t; + + typedef typename Event::base_t base_event_t; + static bool do_transition(T& x, base_event_t const& e) + { + assert(dynamic_cast<event_t const*>(&e) == &e); + return (x.*transition_func)(static_cast<event_t const &>(e)); + } +}; + +}} + +#endif // BOOST_FSM_TRANSITION_INCLUDED diff --git a/src/boost/libs/mpl/example/fsm/player.cpp b/src/boost/libs/mpl/example/fsm/player.cpp new file mode 100644 index 00000000..c3a5a124 --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/player.cpp @@ -0,0 +1,76 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include "state_machine.hpp" +#include <boost/mpl/list.hpp> + +#include <iostream> + +namespace mpl = boost::mpl; + +class player + : public fsm::state_machine<player> +{ + public: + player() {} + + // events + struct play_event : event<play_event> {}; + struct stop_event : event<stop_event> {}; + struct pause_event : event<pause_event> {}; + +// MWCW 8.1 is too eager in inforcing access for non-type template parameters +// private: + typedef player self_t; + + // state invariants + void stopped_state_invariant() const {} + void playing_state_invariant() const {} + void paused_state_invariant() const {} + + // states (invariants are passed as non-type template arguments) + typedef state<0, &self_t::stopped_state_invariant> stopped; + typedef state<1, &self_t::playing_state_invariant> playing; + typedef state<2, &self_t::paused_state_invariant> paused; + +// private: + + // transition functions + bool do_play(play_event const&) { std::cout << "player::do_play\n"; return true; } + bool do_stop(stop_event const&) { std::cout << "player::do_stop\n"; return true; } + bool do_pause(pause_event const&) { std::cout << "player::do_pause\n"; return true; } + bool do_resume(play_event const&) { std::cout << "player::do_resume\n"; return true; } + + // transitions, in the following format: + // | current state | event | next state | transition function | + friend class fsm::state_machine<player>; + typedef mpl::list< + transition<stopped, play_event, playing, &player::do_play> + , transition<playing, stop_event, stopped, &player::do_stop> + , transition<playing, pause_event, paused, &player::do_pause> + , transition<paused, play_event, playing, &player::do_resume> + , transition<paused, stop_event, stopped, &player::do_stop> + >::type transition_table; + + typedef stopped initial_state; +}; + +int main() +{ + player p; + p.process_event(player::play_event()); + p.process_event(player::pause_event()); + p.process_event(player::play_event()); + p.process_event(player::stop_event()); + return 0; +} diff --git a/src/boost/libs/mpl/example/fsm/player1.cpp b/src/boost/libs/mpl/example/fsm/player1.cpp new file mode 100644 index 00000000..a5a1a2cb --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/player1.cpp @@ -0,0 +1,287 @@ +/* + + Copyright David Abrahams 2003-2004 + Copyright Aleksey Gurtovoy 2003-2004 + + Distributed under 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) + + This file was automatically extracted from the source of + "C++ Template Metaprogramming", by David Abrahams and + Aleksey Gurtovoy. + + It was built successfully with GCC 3.4.2 on Windows using + the following command: + + g++ -I..\..\boost_1_32_0 -o%TEMP%\metaprogram-chapter11-example16.exe example16.cpp + + +*/ +#include <boost/mpl/fold.hpp> +#include <boost/mpl/filter_view.hpp> +#include <boost/type_traits/is_same.hpp> +#include <vector> +#include <ctime> +#include <boost/mpl/vector.hpp> + +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/static_assert.hpp> +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +#include <cassert> + +template< + class Transition + , class Next +> +struct event_dispatcher +{ + typedef typename Transition::fsm_t fsm_t; + typedef typename Transition::event event; + + static int dispatch( + fsm_t& fsm, int state, event const& e) + { + if (state == Transition::current_state) + { + Transition::execute(fsm, e); + return Transition::next_state; + } + else // move on to the next node in the chain. + { + return Next::dispatch(fsm, state, e); + } + } +}; + + + +template <class Derived> class state_machine; + +struct default_event_dispatcher +{ + template<class FSM, class Event> + static int dispatch( + state_machine<FSM>& m, int state, Event const& e) + { + return m.call_no_transition(state, e); + } +}; + + + template<class Table, class Event> + struct generate_dispatcher; + +template<class Derived> +class state_machine +{ + // ... + protected: + template< + int CurrentState + , class Event + , int NextState + , void (Derived::*action)(Event const&) + > + struct row + { + // for later use by our metaprogram + static int const current_state = CurrentState; + static int const next_state = NextState; + typedef Event event; + typedef Derived fsm_t; + + // do the transition action. + static void execute(Derived& fsm, Event const& e) + { + (fsm.*action)(e); + } + }; + + + friend class default_event_dispatcher; + + template <class Event> + int call_no_transition(int state, Event const& e) + { + return static_cast<Derived*>(this) // CRTP downcast + ->no_transition(state, e); + } + // +public: + +template<class Event> +int process_event(Event const& evt) +{ + // generate the dispatcher type. + typedef typename generate_dispatcher< + typename Derived::transition_table, Event + >::type dispatcher; + + // dispatch the event. + this->state = dispatcher::dispatch( + *static_cast<Derived*>(this) // CRTP downcast + , this->state + , evt + ); + + // return the new state + return this->state; +} + +// ... + protected: + state_machine() + : state(Derived::initial_state) + { + } + + private: + int state; +// ... + +// ... + public: + template <class Event> + int no_transition(int state, Event const& e) + { + assert(false); + return state; + } +// ... +//// + }; + + +// get the Event associated with a transition. +template <class Transition> +struct transition_event +{ + typedef typename Transition::event type; +}; + +template<class Table, class Event> +struct generate_dispatcher + : mpl::fold< + mpl::filter_view< // select rows triggered by Event + Table + , boost::is_same<Event, transition_event<_1> > + > + , default_event_dispatcher + , event_dispatcher<_2,_1> + > +{}; + + + + struct play {}; + struct open_close {}; + struct cd_detected { + cd_detected(char const*, std::vector<std::clock_t> const&) {} + }; + #ifdef __GNUC__ // in which pause seems to have a predefined meaning + # define pause pause_ + #endif + struct pause {}; + struct stop {}; + + +// concrete FSM implementation +class player : public state_machine<player> +{ + private: + // the list of FSM states + enum states { + Empty, Open, Stopped, Playing, Paused + , initial_state = Empty + }; + + + #ifdef __MWERKS__ + public: // Codewarrior bug workaround. Tested at 0x3202 + #endif + + void start_playback(play const&); + void open_drawer(open_close const&); + void close_drawer(open_close const&); + void store_cd_info(cd_detected const&); + void stop_playback(stop const&); + void pause_playback(pause const&); + void resume_playback(play const&); + void stop_and_open(open_close const&); + + + #ifdef __MWERKS__ + private: + #endif + friend class state_machine<player>; + typedef player p; // makes transition table cleaner + + // transition table + struct transition_table : mpl::vector11< + + // Start Event Next Action + // +---------+-------------+---------+---------------------+ + row < Stopped , play , Playing , &p::start_playback >, + row < Stopped , open_close , Open , &p::open_drawer >, + // +---------+-------------+---------+---------------------+ + row < Open , open_close , Empty , &p::close_drawer >, + // +---------+-------------+---------+---------------------+ + row < Empty , open_close , Open , &p::open_drawer >, + row < Empty , cd_detected , Stopped , &p::store_cd_info >, + // +---------+-------------+---------+---------------------+ + row < Playing , stop , Stopped , &p::stop_playback >, + row < Playing , pause , Paused , &p::pause_playback >, + row < Playing , open_close , Open , &p::stop_and_open >, + // +---------+-------------+---------+---------------------+ + row < Paused , play , Playing , &p::resume_playback >, + row < Paused , stop , Stopped , &p::stop_playback >, + row < Paused , open_close , Open , &p::stop_and_open > + // +---------+-------------+---------+---------------------+ + + > {}; +typedef + +event_dispatcher< + row<Stopped, play, Playing, &player::start_playback> + , event_dispatcher< + row<Paused, play, Playing, &player::resume_playback> + , default_event_dispatcher + > +> + dummy; +}; + + void player::start_playback(play const&){} + void player::open_drawer(open_close const&){} + void player::close_drawer(open_close const&){} + void player::store_cd_info(cd_detected const&){} + void player::stop_playback(stop const&){} + void player::pause_playback(pause const&){} + void player::resume_playback(play const&){} + void player::stop_and_open(open_close const&){} + + + + +int main() +{ + player p; // An instance of the FSM + + p.process_event(open_close()); // user opens CD player + p.process_event(open_close()); // inserts CD and closes + p.process_event( // CD is detected + cd_detected( + "louie, louie" + , std::vector<std::clock_t>( /* track lengths */ ) + ) + ); + p.process_event(play()); // etc. + p.process_event(pause()); + p.process_event(play()); + p.process_event(stop()); + return 0; +} diff --git a/src/boost/libs/mpl/example/fsm/player2.cpp b/src/boost/libs/mpl/example/fsm/player2.cpp new file mode 100644 index 00000000..8704ef5d --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/player2.cpp @@ -0,0 +1,326 @@ +// +// Copyright 2005 David Abrahams and Aleksey Gurtovoy. Distributed +// under 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/mpl/int.hpp" +#include "boost/mpl/fold.hpp" +#include "boost/mpl/prior.hpp" +#include "boost/mpl/count.hpp" +#include "boost/mpl/insert.hpp" +#include <boost/mpl/greater.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/filter_view.hpp> +#include "boost/mpl/vector/vector20.hpp" +#include "boost/assert.hpp" +#include <boost/type_traits/is_same.hpp> + +#include <vector> +#include <ctime> +#include <iostream> + +#if defined(BOOST_DINKUMWARE_STDLIB) && BOOST_DINKUMWARE_STDLIB < 310 +namespace std { using ::clock_t; } +#endif + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +// A metafunction that returns the Event associated with a transition. +template <class Transition> +struct transition_event +{ + typedef typename Transition::event type; +}; + +// A metafunction computing the maximum of a transition's source and +// end states. +template <class Transition> +struct transition_max_state +{ + typedef typename mpl::int_< + (Transition::current_state > Transition::next_state) + ? Transition::current_state + : Transition::next_state + > type; +}; + +template<class Derived> +class state_machine; + +// Generates a singleton runtime lookup table that maps current state +// to a function that makes the FSM take its transition on the given +// Event type. +template <class Fsm, int initial_state, class Stt, class Event> +struct dispatch_table +{ + private: + // This is a table of these function pointers. + typedef int (*cell)(Fsm&, int, Event const&); + + // Compute the maximum state value in the Fsm so we know how big + // to make the table + BOOST_STATIC_CONSTANT( + int, max_state = ( + mpl::fold<Stt + , mpl::int_<initial_state> + , mpl::if_< + mpl::greater<transition_max_state<_2>,_1> + , transition_max_state<_2> + , _1 + > + >::type::value + ) + ); + + // A function object for use with mpl::for_each that stuffs + // transitions into cells. + struct init_cell + { + init_cell(dispatch_table* self_) + : self(self_) + {} + + // Cell initializer function object, used with mpl::for_each + template <class Transition> + void operator()(Transition const&) const + { + self->entries[Transition::current_state] = &Transition::execute; + } + + dispatch_table* self; + }; + + public: + // initialize the dispatch table for a given Event and Fsm + dispatch_table() + { + // Initialize cells for no transition + for (int i = 0; i <= max_state; ++i) + { + // VC7.1 seems to need the two-phase assignment. + cell call_no_transition = &state_machine<Fsm>::call_no_transition; + entries[i] = call_no_transition; + } + + // Go back and fill in cells for matching transitions. + mpl::for_each< + mpl::filter_view< + Stt + , boost::is_same<transition_event<_>, Event> + > + >(init_cell(this)); + } + + // The singleton instance. + static const dispatch_table instance; + + public: // data members + cell entries[max_state + 1]; +}; + +// This declares the statically-initialized dispatch_table instance. +template <class Fsm, int initial_state, class Stt, class Event> +const dispatch_table<Fsm, initial_state, Stt, Event> +dispatch_table<Fsm, initial_state, Stt, Event>::instance; + +// CRTP base class for state machines. Pass the actual FSM class as +// the Derived parameter. +template<class Derived> +class state_machine +{ + public: // Member functions + + // Main function used by clients of the derived FSM to make + // transitions. + template<class Event> + int process_event(Event const& evt) + { + typedef typename Derived::transition_table stt; + typedef dispatch_table<Derived, Derived::initial_state,stt,Event> table; + + // Call the action + return this->m_state + = table::instance.entries[this->m_state]( + *static_cast<Derived*>(this), this->m_state, evt); + } + + // Getter that returns the current state of the FSM + int current_state() const + { + return this->m_state; + } + + private: + template <class Fsm, int initial_state, class Stt, class Event> + friend class dispatch_table; + + template <class Event> + static int call_no_transition(Derived& fsm, int state, Event const& e) + { + return fsm.no_transition(state, e); + } + + // Default no-transition handler. Can be replaced in the Derived + // FSM class. + template <class Event> + int no_transition(int state, Event const& e) + { + BOOST_ASSERT(false); + return state; + } + + protected: // interface for the derived class + + template<class State> + state_machine(State state) // Construct with an initial state + : m_state(state) + { + } + + state_machine() + : m_state(Derived::initial_state) // Construct with the default initial_state + { + } + + // Template used to form rows in the transition table + template< + int CurrentState + , class Event + , int NextState + , void (Derived::*action)(Event const&) + > + struct row + { + BOOST_STATIC_CONSTANT(int, current_state = CurrentState); + BOOST_STATIC_CONSTANT(int, next_state = NextState); + typedef Event event; + + // Take the transition action and return the next state. + static int execute(Derived& fsm, int state, Event const& evt) + { + BOOST_ASSERT(state == current_state); + (fsm.*action)(evt); + return next_state; + } + }; + + private: // data members + int m_state; +}; + +namespace // Concrete FSM implementation +{ + // events + struct play {}; + struct stop {}; + struct pause {}; + struct open_close {}; + + // A "complicated" event type that carries some data. + struct cd_detected + { + cd_detected(std::string name, std::vector<std::clock_t> durations) + : name(name) + , track_durations(durations) + {} + + std::string name; + std::vector<std::clock_t> track_durations; + }; + + // Concrete FSM implementation + class player : public state_machine<player> + { + // The list of FSM states + enum states { + Empty, Open, Stopped, Playing, Paused + , initial_state = Empty + }; + +#ifdef __MWERKS__ + public: // Codewarrior bug workaround. Tested at 0x3202 +#endif + // transition actions + void start_playback(play const&) { std::cout << "player::start_playback\n"; } + void open_drawer(open_close const&) { std::cout << "player::open_drawer\n"; } + void close_drawer(open_close const&) { std::cout << "player::close_drawer\n"; } + void store_cd_info(cd_detected const&) { std::cout << "player::store_cd_info\n"; } + void stop_playback(stop const&) { std::cout << "player::stop_playback\n"; } + void pause_playback(pause const&) { std::cout << "player::pause_playback\n"; } + void resume_playback(play const&) { std::cout << "player::resume_playback\n"; } + void stop_and_open(open_close const&) { std::cout << "player::stop_and_open\n"; } +#ifdef __MWERKS__ + private: +#endif + friend class state_machine<player>; + typedef player p; // makes transition table cleaner + + // Transition table + struct transition_table : mpl::vector11< + // Start Event Next Action + // +---------+-------------+---------+---------------------+ + row < Stopped , play , Playing , &p::start_playback >, + row < Stopped , open_close , Open , &p::open_drawer >, + // +---------+-------------+---------+---------------------+ + row < Open , open_close , Empty , &p::close_drawer >, + // +---------+-------------+---------+---------------------+ + row < Empty , open_close , Open , &p::open_drawer >, + row < Empty , cd_detected , Stopped , &p::store_cd_info >, + // +---------+-------------+---------+---------------------+ + row < Playing , stop , Stopped , &p::stop_playback >, + row < Playing , pause , Paused , &p::pause_playback >, + row < Playing , open_close , Open , &p::stop_and_open >, + // +---------+-------------+---------+---------------------+ + row < Paused , play , Playing , &p::resume_playback >, + row < Paused , stop , Stopped , &p::stop_playback >, + row < Paused , open_close , Open , &p::stop_and_open > + // +---------+-------------+---------+---------------------+ + > {}; + + // Replaces the default no-transition response. + template <class Event> + int no_transition(int state, Event const& e) + { + std::cout << "no transition from state " << state + << " on event " << typeid(e).name() << std::endl; + return state; + } + }; + + // + // Testing utilities. + // + static char const* const state_names[] = { "Empty", "Open", "Stopped", "Playing", "Paused" }; + + void pstate(player const& p) + { + std::cout << " -> " << state_names[p.current_state()] << std::endl; + } + + void test() + { + player p; + p.process_event(open_close()); pstate(p); + p.process_event(open_close()); pstate(p); + p.process_event( + cd_detected( + "louie, louie" + , std::vector<std::clock_t>( /* track lengths */ ) + ) + ); + pstate(p); + + p.process_event(play()); pstate(p); + p.process_event(pause()); pstate(p); + p.process_event(play()); pstate(p); + p.process_event(stop()); pstate(p); + } +} + +int main() +{ + test(); + return 0; +} diff --git a/src/boost/libs/mpl/example/fsm/state_machine.hpp b/src/boost/libs/mpl/example/fsm/state_machine.hpp new file mode 100644 index 00000000..4bfd0169 --- /dev/null +++ b/src/boost/libs/mpl/example/fsm/state_machine.hpp @@ -0,0 +1,145 @@ + +#ifndef BOOST_FSM_STATE_MACHINE_INCLUDED +#define BOOST_FSM_STATE_MACHINE_INCLUDED + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include "aux_/event.hpp" +#include "aux_/state.hpp" +#include "aux_/transition.hpp" +#include "aux_/STT_impl_gen.hpp" +#include <boost/shared_ptr.hpp> + +#include <queue> +#include <memory> +#include <cassert> + +namespace fsm { + +template< typename Derived > +class state_machine +{ + private: + typedef state_machine self_t; + typedef aux::base_event base_event_t; + typedef boost::shared_ptr<base_event_t const> base_event_ptr_t; + + public: + typedef long state_t; + typedef void (Derived::* invariant_func_t)() const; + + template< typename DerivedEvent > + struct event + : aux::event<DerivedEvent> + { + }; + + void process_event(base_event_t const& evt) + { + // all internal events should be handled at this point + assert(!m_events_queue.size()); + + // process the external event passed + do_transition(evt); + + // if the previous transition generated any internal events, + // process those + while (m_events_queue.size()) + { + do_transition(*m_events_queue.front()); + m_events_queue.pop(); + } + } + + state_t current_state() const + { + return m_state; + } + + protected: + // interface for the derived class + + state_machine(state_t const& initial_state) + : m_state(initial_state) + { + } + + state_machine() + : m_state(typename Derived::initial_state()) + { + } + + virtual ~state_machine() + { + } + + +#if defined(BOOST_NO_CXX11_SMART_PTR) + + void post_event(std::auto_ptr<base_event_t const> evt) + +#else + + void post_event(std::unique_ptr<base_event_t const> evt) + +#endif + + { + m_events_queue.push(base_event_ptr_t(evt.release())); + } + + template< + long State +#if !defined(BOOST_INTEL_CXX_VERSION) && (!defined(__GNUC__) || __GNUC__ >= 3) + , invariant_func_t f = static_cast<invariant_func_t>(0) +#else + , invariant_func_t f = 0 +#endif + > + struct state + : fsm::aux::state<Derived,State,f> + { + }; + + template< + typename From + , typename Event + , typename To + , bool (Derived::* transition_func)(Event const&) + > + struct transition + : aux::transition< Derived,From,Event,To,transition_func > + { + }; + + private: + + void do_transition(base_event_t const& evt) + { + typedef typename Derived::transition_table STT_; + typedef typename aux::STT_impl_gen< STT_ >::type STT_impl_; + + m_state = STT_impl_::do_transition( + static_cast<Derived&>(*this) + , m_state + , evt + ); + } + + state_t m_state; + std::queue< base_event_ptr_t > m_events_queue; +}; + +} // namespace fsm + +#endif // BOOST_FSM_STATE_MACHINE_INCLUDED diff --git a/src/boost/libs/mpl/example/inherit_linearly.cpp b/src/boost/libs/mpl/example/inherit_linearly.cpp new file mode 100644 index 00000000..368be77c --- /dev/null +++ b/src/boost/libs/mpl/example/inherit_linearly.cpp @@ -0,0 +1,62 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/inherit_linearly.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/list.hpp> + +#include <iostream> + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +template< typename Base, typename T > +struct tuple_part + : Base +{ + typedef tuple_part type; // note the typedef + typedef typename Base::index::next index; + + friend T& field(tuple_part& t, index) { return t.field_; } + T field_; +}; + +struct empty_tuple +{ + typedef mpl::int_<-1> index; +}; + + +typedef mpl::inherit_linearly< + mpl::list<int,char const*,bool> + , tuple_part<_,_> + , empty_tuple + >::type my_tuple; + + +int main() +{ + my_tuple t; + + field(t, mpl::int_<0>()) = -1; + field(t, mpl::int_<1>()) = "text"; + field(t, mpl::int_<2>()) = false; + + std::cout + << field(t, mpl::int_<0>()) << '\n' + << field(t, mpl::int_<1>()) << '\n' + << field(t, mpl::int_<2>()) << '\n' + ; + + return 0; +} diff --git a/src/boost/libs/mpl/example/inherit_multiply.cpp b/src/boost/libs/mpl/example/inherit_multiply.cpp new file mode 100644 index 00000000..e8a6fde2 --- /dev/null +++ b/src/boost/libs/mpl/example/inherit_multiply.cpp @@ -0,0 +1,58 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/inherit.hpp> +#include <boost/mpl/inherit_linearly.hpp> +#include <boost/mpl/list.hpp> + +#include <iostream> + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +template< typename T > +struct tuple_field +{ + typedef tuple_field type; // note the typedef + T field_; +}; + +template< typename T > +inline +T& field(tuple_field<T>& t) +{ + return t.field_; +} + +typedef mpl::inherit_linearly< + mpl::list<int,char const*,bool> + , mpl::inherit< _1, tuple_field<_2> > + >::type my_tuple; + + +int main() +{ + my_tuple t; + + field<int>(t) = -1; + field<char const*>(t) = "text"; + field<bool>(t) = false; + + std::cout + << field<int>(t) << '\n' + << field<char const*>(t) << '\n' + << field<bool>(t) << '\n' + ; + + return 0; +} diff --git a/src/boost/libs/mpl/example/integer.cpp b/src/boost/libs/mpl/example/integer.cpp new file mode 100644 index 00000000..879c4134 --- /dev/null +++ b/src/boost/libs/mpl/example/integer.cpp @@ -0,0 +1,67 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/multiplies.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/lower_bound.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/sizeof.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/base.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/deref.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/assert.hpp> + +#include <boost/type_traits/is_same.hpp> + +namespace mpl = boost::mpl; +using namespace mpl::placeholders; + +template< int bit_size > +class big_int +{ + // ... +}; + +template< int bit_size > +struct integer +{ + typedef mpl::list<char,short,int,long> builtins_; + typedef typename mpl::base< typename mpl::lower_bound< + mpl::transform_view< builtins_ + , mpl::multiplies< mpl::sizeof_<_1>, mpl::int_<8> > + > + , mpl::int_<bit_size> + >::type >::type iter_; + + typedef typename mpl::end<builtins_>::type last_; + typedef typename mpl::eval_if< + boost::is_same<iter_,last_> + , mpl::identity< big_int<bit_size> > + , mpl::deref<iter_> + >::type type; +}; + +typedef integer<1>::type int1; +typedef integer<5>::type int5; +typedef integer<15>::type int15; +typedef integer<32>::type int32; +typedef integer<100>::type int100; + +BOOST_MPL_ASSERT(( boost::is_same< int1, char > )); +BOOST_MPL_ASSERT(( boost::is_same< int5, char > )); +BOOST_MPL_ASSERT(( boost::is_same< int15, short > )); +BOOST_MPL_ASSERT(( boost::is_same< int32, int > )); +BOOST_MPL_ASSERT(( boost::is_same< int100, big_int<100> > )); diff --git a/src/boost/libs/mpl/example/tuple_from_list.cpp b/src/boost/libs/mpl/example/tuple_from_list.cpp new file mode 100644 index 00000000..bf5c6a9e --- /dev/null +++ b/src/boost/libs/mpl/example/tuple_from_list.cpp @@ -0,0 +1,46 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/reverse_fold.hpp> +#include <boost/mpl/list.hpp> +#include <boost/tuple/tuple.hpp> + +#include <iostream> + +using namespace boost::mpl; + +template< typename Types > struct tuple_gen + : reverse_fold< + Types + , boost::tuples::null_type + , boost::tuples::cons<_2,_1> + > +{ +}; + +int main() +{ + tuple_gen< list<int,char const*,bool> >::type t; + + boost::get<0>(t) = -1; + boost::get<1>(t) = "text"; + boost::get<2>(t) = false; + + std::cout + << boost::get<0>(t) << '\n' + << boost::get<1>(t) << '\n' + << boost::get<2>(t) << '\n' + ; + + return 0; +} diff --git a/src/boost/libs/mpl/index.html b/src/boost/libs/mpl/index.html new file mode 100644 index 00000000..4540421a --- /dev/null +++ b/src/boost/libs/mpl/index.html @@ -0,0 +1,13 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/index.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="doc/index.html">doc/index.html</a>. <hr> +<p>© Copyright Beman Dawes, 2001</p> +<p>Distributed under the Boost Software License, Version 1.0. (See accompanying +file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy +at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p> +</body> +</html>
\ No newline at end of file diff --git a/src/boost/libs/mpl/meta/libraries.json b/src/boost/libs/mpl/meta/libraries.json new file mode 100644 index 00000000..6f7bd4c7 --- /dev/null +++ b/src/boost/libs/mpl/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "mpl", + "name": "MPL", + "authors": [ + "Aleksey Gurtovoy" + ], + "description": "The Boost.MPL library is a general-purpose, high-level C++ template metaprogramming framework of compile-time algorithms, sequences and metafunctions. It provides a conceptual foundation and an extensive set of powerful and coherent tools that make doing explict metaprogramming in C++ as easy and enjoyable as possible within the current language.", + "category": [ + "Metaprogramming" + ], + "maintainers": [ + "Aleksey Gurtovoy <agurtovoy -at- meta-comm.com>" + ] +} diff --git a/src/boost/libs/mpl/preprocessed/README.txt b/src/boost/libs/mpl/preprocessed/README.txt new file mode 100644 index 00000000..75ae37f0 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/README.txt @@ -0,0 +1,70 @@ +Pre-processing of MPL-containers +-------------------------------- + +Pre-processing of MPL-containers can be accomplished using the script +"boost_mpl_preprocess.py". In the simple case call it with a single +argument which is the path to the source-directory of Boost. + + python boost_mpl_preprocess.py <path-to-boost-sourcedir> + +If the Boost source-directory is the one this script resides in, you +can just call it without any arguments. + + python boost_mpl_preprocess.py + +Either way, this will pre-process all four MPL-container types (vector, +list, set, map) and makes them able to hold up to 100 elements. They can +be used either in their 'numbered' or their 'variadic' form. + +Additionally, the script also allows more fine-grained pre-processing. +The maximal number of elements an MPL-container type is able to hold can +be different from the one of other MPL-container types and it can also +differ between its 'numbered' and 'variadic' form. +To see all options, call the script like this: + + python boost_mpl_preprocess.py --help + + +Fixing pre-processing of MPL-containers +--------------------------------------- + +Sadly, pre-processing of MPL-containers might fail, if the source-files +used as input are missing some header-comments required during the pre- +processing step. +However, the script "boost_mpl_preprocess.py" makes sure to patch these +input source-files prior to pre-processing (by implicitly calling script +"fix_boost_mpl_preprocess.py" with the chosen settings). It only patches +the source-files needed for pre-processing the selected MPL-container +types and their selected form ('numbered' or 'variadic'). +If calling it with a single (or no) argument (as in the former section) +all input source-files will be patched automatically. + +Instead of fixing the input-files implicitly during pre-processing one +can also fix them explicitly by calling "fix_boost_mpl_preprocess.py" +directly. +If you just want to test if any fixing is needed call it like this: + + python fix_boost_mpl_preprocess.py --check-only <path-to-boost-sourcedir> + +This will tell you if any fixing is needed. In such a case call the script +"fix_boost_mpl_preprocess.py" like this: + + python fix_boost_mpl_preprocess.py <path-to-boost-sourcedir> + +This will fix the header-comments of all the source-files needed during +pre-processing. Calling "boost_mpl_preprocess.py" afterwards should then +successfully pre-process the MPL-containers (without the need of implicitly +fixing any files again). + +Note: +Failure of pre-processing can be checked by examining at least one of the +following directories in which automatically generated files will be put +during pre-processing. If at least one file in these directories (or sub- +directories therein) has a size of zero bytes, fixing is needed. + + <path-to-boost-sourcedir>/boost/mpl/vector/aux_/preprocessed/ + <path-to-boost-sourcedir>/boost/mpl/list/aux_/preprocessed/ + <path-to-boost-sourcedir>/boost/mpl/set/aux_/preprocessed/ + <path-to-boost-sourcedir>/boost/mpl/map/aux_/preprocessed/ + <path-to-boost-sourcedir>/boost/mpl/aux_/preprocessed/ + diff --git a/src/boost/libs/mpl/preprocessed/boost_mpl_preprocess.py b/src/boost/libs/mpl/preprocessed/boost_mpl_preprocess.py new file mode 100755 index 00000000..b4973910 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/boost_mpl_preprocess.py @@ -0,0 +1,250 @@ +# Copyright Deniz Bahadir 2015 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. +# See http://stackoverflow.com/a/20660264/3115457 for further information. +# See http://stackoverflow.com/a/29627158/3115457 for further information. + +import fix_boost_mpl_preprocess as fixmpl +import argparse +import sys +import os +import os.path +import re +import fileinput +import shutil + + +def create_more_container_files(sourceDir, suffix, maxElements, containers, containers2): + """Creates additional files for the individual MPL-containers.""" + + # Create files for each MPL-container with 20 to 'maxElements' elements + # which will be used during generation. + for container in containers: + for i in range(20, maxElements, 10): + # Create copy of "template"-file. + newFile = os.path.join( sourceDir, container, container + str(i+10) + suffix ) + shutil.copyfile( os.path.join( sourceDir, container, container + "20" + suffix ), newFile ) + # Adjust copy of "template"-file accordingly. + for line in fileinput.input( newFile, inplace=1, mode="rU" ): + line = re.sub(r'20', '%TWENTY%', line.rstrip()) + line = re.sub(r'11', '%ELEVEN%', line.rstrip()) + line = re.sub(r'10(?![0-9])', '%TEN%', line.rstrip()) + line = re.sub(r'%TWENTY%', re.escape(str(i+10)), line.rstrip()) + line = re.sub(r'%ELEVEN%', re.escape(str(i + 1)), line.rstrip()) + line = re.sub(r'%TEN%', re.escape(str(i)), line.rstrip()) + print(line) + for container in containers2: + for i in range(20, maxElements, 10): + # Create copy of "template"-file. + newFile = os.path.join( sourceDir, container, container + str(i+10) + "_c" + suffix ) + shutil.copyfile( os.path.join( sourceDir, container, container + "20_c" + suffix ), newFile ) + # Adjust copy of "template"-file accordingly. + for line in fileinput.input( newFile, inplace=1, mode="rU" ): + line = re.sub(r'20', '%TWENTY%', line.rstrip()) + line = re.sub(r'11', '%ELEVEN%', line.rstrip()) + line = re.sub(r'10(?![0-9])', '%TEN%', line.rstrip()) + line = re.sub(r'%TWENTY%', re.escape(str(i+10)), line.rstrip()) + line = re.sub(r'%ELEVEN%', re.escape(str(i + 1)), line.rstrip()) + line = re.sub(r'%TEN%', re.escape(str(i)), line.rstrip()) + print(line) + + +def create_input_for_numbered_sequences(headerDir, sourceDir, containers, maxElements): + """Creates additional source- and header-files for the numbered sequence MPL-containers.""" + # Create additional container-list without "map". + containersWithoutMap = containers[:] + try: + containersWithoutMap.remove('map') + except ValueError: + # We can safely ignore if "map" is not contained in 'containers'! + pass + # Create header/source-files. + create_more_container_files(headerDir, ".hpp", maxElements, containers, containersWithoutMap) + create_more_container_files(sourceDir, ".cpp", maxElements, containers, containersWithoutMap) + + +def adjust_container_limits_for_variadic_sequences(headerDir, containers, maxElements): + """Adjusts the limits of variadic sequence MPL-containers.""" + for container in containers: + headerFile = os.path.join( headerDir, "limits", container + ".hpp" ) + regexMatch = r'(define\s+BOOST_MPL_LIMIT_' + container.upper() + r'_SIZE\s+)[0-9]+' + regexReplace = r'\g<1>' + re.escape( str(maxElements) ) + for line in fileinput.input( headerFile, inplace=1, mode="rU" ): + line = re.sub(regexMatch, regexReplace, line.rstrip()) + print(line) + + +def current_boost_dir(): + """Returns the (relative) path to the Boost source-directory this file is located in (if any).""" + # Path to directory containing this script. + path = os.path.dirname( os.path.realpath(__file__) ) + # Making sure it is located in "${boost-dir}/libs/mpl/preprocessed". + for directory in reversed( ["libs", "mpl", "preprocessed"] ): + (head, tail) = os.path.split(path) + if tail == directory: + path = head + else: + return None + return os.path.relpath( path ) + + + +def to_positive_multiple_of_10(string): + """Converts a string into its encoded positive integer (greater zero) or throws an exception.""" + try: + value = int(string) + except ValueError: + msg = '"%r" is not a positive multiple of 10 (greater zero).' % string + raise argparse.ArgumentTypeError(msg) + if value <= 0 or value % 10 != 0: + msg = '"%r" is not a positive multiple of 10 (greater zero).' % string + raise argparse.ArgumentTypeError(msg) + return value + + +def to_existing_absolute_path(string): + """Converts a path into its absolute path and verifies that it exists or throws an exception.""" + value = os.path.abspath(string) + if not os.path.exists( value ) or not os.path.isdir( value ): + msg = '"%r" is not a valid path to a directory.' % string + raise argparse.ArgumentTypeError(msg) + return value + + +def main(): + """The main function.""" + + # Find the current Boost source-directory in which this script is located. + sourceDir = current_boost_dir() + if sourceDir == None: + sourceDir = "" + + # Prepare and run cmdline-parser. + cmdlineParser = argparse.ArgumentParser(description="A generator-script for pre-processed Boost.MPL headers.") + cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true', + help="Be a little bit more verbose.") + cmdlineParser.add_argument("-s", "--sequence-type", dest='seqType', choices=['variadic', 'numbered', 'both'], + default='both', + help="Only update pre-processed headers for the selected sequence types, " + "either 'numbered' sequences, 'variadic' sequences or 'both' sequence " + "types. (Default=both)") + cmdlineParser.add_argument("--no-vector", dest='want_vector', action='store_false', + help="Do not update pre-processed headers for Boost.MPL Vector.") + cmdlineParser.add_argument("--no-list", dest='want_list', action='store_false', + help="Do not update pre-processed headers for Boost.MPL List.") + cmdlineParser.add_argument("--no-set", dest='want_set', action='store_false', + help="Do not update pre-processed headers for Boost.MPL Set.") + cmdlineParser.add_argument("--no-map", dest='want_map', action='store_false', + help="Do not update pre-processed headers for Boost.MPL Map.") + cmdlineParser.add_argument("--num-elements", dest='numElements', metavar="<num-elements>", + type=to_positive_multiple_of_10, default=100, + help="The maximal number of elements per container sequence. (Default=100)") + cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>", default=current_boost_dir(), nargs='?', + type=to_existing_absolute_path, + help="The source-directory of Boost. (Default=\"" + sourceDir + "\")") + args = cmdlineParser.parse_args() + + # Some verbose debug output. + if args.verbose: + print "Arguments extracted from command-line:" + print " verbose = ", args.verbose + print " source directory = ", args.sourceDir + print " num elements = ", args.numElements + print " sequence type = ", args.seqType + print " want: vector = ", args.want_vector + print " want: list = ", args.want_list + print " want: set = ", args.want_set + print " want: map = ", args.want_map + + # Verify that we received any source-directory. + if args.sourceDir == None: + print "You should specify a valid path to the Boost source-directory." + sys.exit(0) + + # The directories for header- and source files of Boost.MPL. + # NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project. + headerDir = os.path.join( args.sourceDir, "boost", "mpl" ) + sourceDir = os.path.join( args.sourceDir, "libs", "mpl", "preprocessed" ) + # Check that the header/source-directories exist. + if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ): + # Maybe 'args.sourceDir' is not the source-directory of the entire boost project + # but instead of the Boost.MPL git-directory, only? + headerDir = os.path.join( args.sourceDir, "include", "boost", "mpl" ) + sourceDir = os.path.join( args.sourceDir, "preprocessed" ) + if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ): + cmdlineParser.print_usage() + print "error: Cannot find Boost.MPL header/source files in given Boost source-directory!" + sys.exit(0) + + # Some verbose debug output. + if args.verbose: + print "Chosen header-directory: ", headerDir + print "Chosen source-directory: ", sourceDir + + # Create list of containers for which files shall be pre-processed. + containers = [] + if args.want_vector: + containers.append('vector') + if args.want_list: + containers.append('list') + if args.want_set: + containers.append('set') + if args.want_map: + containers.append('map') + if containers == []: + print "Nothing to do." + print "(Why did you prevent generating pre-processed headers for all Boost.MPL container types?)" + sys.exit(0) + + # Possibly fix the header-comments of input-files needed for pre-processing. + if args.verbose: + print "Checking if prior to pre-processing some input-files need fixing." + needFixing = fixmpl.check_input_files(headerDir, sourceDir, containers, args.seqType, args.verbose) + if needFixing: + if args.verbose: + print "Fixing of some input-files prior to pre-processing is needed." + print "Will fix them now!" + fixmpl.fix_input_files(headerDir, sourceDir, containers, args.seqType, args.verbose) + + # Some verbose debug output. + if args.verbose: + print "Containers for which to pre-process headers: ", containers + + # Create (additional) input files for generating pre-processed headers of numbered sequence MPL containers. + if args.seqType == "both" or args.seqType == "numbered": + create_input_for_numbered_sequences(headerDir, sourceDir, containers, args.numElements) + # Modify settings for generating pre-processed headers of variadic sequence MPL containers. + if args.seqType == "both" or args.seqType == "variadic": + adjust_container_limits_for_variadic_sequences(headerDir, containers, args.numElements) + + # Generate MPL-preprocessed files. + os.chdir( sourceDir ) + if args.seqType == "both" or args.seqType == "numbered": + if args.want_vector: + if args.verbose: + print "Pre-process headers for Boost.MPL numbered vectors." + os.system( "python " + os.path.join( sourceDir, "preprocess_vector.py" ) + " all " + args.sourceDir ) + if args.want_list: + if args.verbose: + print "Pre-process headers for Boost.MPL numbered lists." + os.system( "python " + os.path.join( sourceDir, "preprocess_list.py" ) + " all " + args.sourceDir ) + if args.want_set: + if args.verbose: + print "Pre-process headers for Boost.MPL numbered sets." + os.system( "python " + os.path.join( sourceDir, "preprocess_set.py" ) + " all " + args.sourceDir ) + if args.want_map: + if args.verbose: + print "Pre-process headers for Boost.MPL numbered maps." + os.system( "python " + os.path.join( sourceDir, "preprocess_map.py" ) + " all " + args.sourceDir ) + if args.seqType == "both" or args.seqType == "variadic": + if args.verbose: + print "Pre-process headers for Boost.MPL variadic containers." + os.system( "python " + os.path.join( sourceDir, "preprocess.py" ) + " all " + args.sourceDir ) + + +if __name__ == '__main__': + main() diff --git a/src/boost/libs/mpl/preprocessed/fix_boost_mpl_preprocess.py b/src/boost/libs/mpl/preprocessed/fix_boost_mpl_preprocess.py new file mode 100755 index 00000000..3b92d25d --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/fix_boost_mpl_preprocess.py @@ -0,0 +1,205 @@ +# Copyright Deniz Bahadir 2015 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. +# See http://stackoverflow.com/a/29627158/3115457 for further information. + +import argparse +import sys +import os.path +import re +import fileinput +import datetime +import glob + + +def check_header_comment(filename): + """Checks if the header-comment of the given file needs fixing.""" + # Check input file. + name = os.path.basename( filename ) + # Read content of input file. + sourcefile = open( filename, "rU" ) + content = sourcefile.read() + sourcefile.close() + # Search content for '$Id$'. + match = re.search(r'\$Id\$', content) + if match == None: + # Make sure that the correct value for '$Id$' was already set. + match = re.search(r'\$Id: ' + name + r'\s+[^$]+\$', content) + if match != None: + # The given file needs no fixing. + return False + # The given file needs fixing. + return True + + +def check_input_files_for_variadic_seq(headerDir, sourceDir): + """Checks if files, used as input when pre-processing MPL-containers in their variadic form, need fixing.""" + # Check input files in include/source-directories. + files = glob.glob( os.path.join( headerDir, "*.hpp" ) ) + files += glob.glob( os.path.join( headerDir, "aux_", "*.hpp" ) ) + files += glob.glob( os.path.join( sourceDir, "src", "*" ) ) + for currentFile in sorted( files ): + if check_header_comment( currentFile ): + return True + return False + + +def check_input_files_for_numbered_seq(sourceDir, suffix, containers): + """Check if files, used as input when pre-processing MPL-containers in their numbered form, need fixing.""" + # Check input files for each MPL-container type. + for container in containers: + files = glob.glob( os.path.join( sourceDir, container, container + '*' + suffix ) ) + for currentFile in sorted( files ): + if check_header_comment( currentFile ): + return True + return False + + +def check_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'], + seqType='both', verbose=False): + """Checks if source- and header-files, used as input when pre-processing MPL-containers, need fixing.""" + # Check the input files for containers in their variadic form. + result1 = False + if seqType == "both" or seqType == "variadic": + if verbose: + print "Check if input files for pre-processing Boost.MPL variadic containers need fixing." + result1 = check_input_files_for_variadic_seq(headerDir, sourceDir) + if verbose: + if result1: + print " At least one input file needs fixing!" + else: + print " No input file needs fixing!" + # Check the input files for containers in their numbered form. + result2 = False + result3 = False + if seqType == "both" or seqType == "numbered": + if verbose: + print "Check input files for pre-processing Boost.MPL numbered containers." + result2 = check_input_files_for_numbered_seq(headerDir, ".hpp", containers) + result3 = check_input_files_for_numbered_seq(sourceDir, ".cpp", containers) + if verbose: + if result2 or result3: + print " At least one input file needs fixing!" + else: + print " No input file needs fixing!" + # Return result. + return result1 or result2 or result3 + +def fix_header_comment(filename, timestamp): + """Fixes the header-comment of the given file.""" + # Fix input file. + name = os.path.basename( filename ) + for line in fileinput.input( filename, inplace=1, mode="rU" ): + # If header-comment already contains anything for '$Id$', remove it. + line = re.sub(r'\$Id:[^$]+\$', r'$Id$', line.rstrip()) + # Replace '$Id$' by a string containing the file's name (and a timestamp)! + line = re.sub(re.escape(r'$Id$'), r'$Id: ' + name + r' ' + timestamp.isoformat() + r' $', line.rstrip()) + print(line) + + +def fix_input_files_for_variadic_seq(headerDir, sourceDir, timestamp): + """Fixes files used as input when pre-processing MPL-containers in their variadic form.""" + # Fix files in include/source-directories. + files = glob.glob( os.path.join( headerDir, "*.hpp" ) ) + files += glob.glob( os.path.join( headerDir, "aux_", "*.hpp" ) ) + files += glob.glob( os.path.join( sourceDir, "src", "*" ) ) + for currentFile in sorted( files ): + fix_header_comment( currentFile, timestamp ) + + +def fix_input_files_for_numbered_seq(sourceDir, suffix, timestamp, containers): + """Fixes files used as input when pre-processing MPL-containers in their numbered form.""" + # Fix input files for each MPL-container type. + for container in containers: + files = glob.glob( os.path.join( sourceDir, container, container + '*' + suffix ) ) + for currentFile in sorted( files ): + fix_header_comment( currentFile, timestamp ) + + +def fix_input_files(headerDir, sourceDir, containers=['vector', 'list', 'set', 'map'], + seqType='both', verbose=False): + """Fixes source- and header-files used as input when pre-processing MPL-containers.""" + # The new modification time. + timestamp = datetime.datetime.now(); + # Fix the input files for containers in their variadic form. + if seqType == "both" or seqType == "variadic": + if verbose: + print "Fix input files for pre-processing Boost.MPL variadic containers." + fix_input_files_for_variadic_seq(headerDir, sourceDir, timestamp) + # Fix the input files for containers in their numbered form. + if seqType == "both" or seqType == "numbered": + if verbose: + print "Fix input files for pre-processing Boost.MPL numbered containers." + fix_input_files_for_numbered_seq(headerDir, ".hpp", timestamp, containers) + fix_input_files_for_numbered_seq(sourceDir, ".cpp", timestamp, containers) + + +def to_existing_absolute_path(string): + """Converts a path into its absolute path and verifies that it exists or throws an exception.""" + value = os.path.abspath(string) + if not os.path.exists( value ) or not os.path.isdir( value ): + msg = '"%r" is not a valid path to a directory.' % string + raise argparse.ArgumentTypeError(msg) + return value + + +def main(): + """The main function.""" + + # Prepare and run cmdline-parser. + cmdlineParser = argparse.ArgumentParser( + description="Fixes the input files used for pre-processing of Boost.MPL headers.") + cmdlineParser.add_argument("-v", "--verbose", dest='verbose', action='store_true', + help="Be a little bit more verbose.") + cmdlineParser.add_argument("--check-only", dest='checkonly', action='store_true', + help="Only checks if fixing is required.") + cmdlineParser.add_argument(dest='sourceDir', metavar="<source-dir>", + type=to_existing_absolute_path, + help="The source-directory of Boost.") + args = cmdlineParser.parse_args() + + # Some verbose debug output. + if args.verbose: + print "Arguments extracted from command-line:" + print " verbose = ", args.verbose + print " check-only = ", args.checkonly + print " source directory = ", args.sourceDir + + # The directories for header- and source files of Boost.MPL. + # NOTE: Assuming 'args.sourceDir' is the source-directory of the entire boost project. + headerDir = os.path.join( args.sourceDir, "boost", "mpl" ) + sourceDir = os.path.join( args.sourceDir, "libs", "mpl", "preprocessed" ) + # Check that the header/source-directories exist. + if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ): + # Maybe 'args.sourceDir' is not the source-directory of the entire boost project + # but instead of the Boost.MPL git-directory, only? + headerDir = os.path.join( args.sourceDir, "include", "boost", "mpl" ) + sourceDir = os.path.join( args.sourceDir, "preprocessed" ) + if not os.path.exists( headerDir ) or not os.path.exists( sourceDir ): + cmdlineParser.print_usage() + print "error: Cannot find Boost.MPL header/source files in given Boost source-directory!" + sys.exit(0) + + # Some verbose debug output. + if args.verbose: + print "Chosen header-directory: ", headerDir + print "Chosen source-directory: ", sourceDir + + if args.checkonly: + # Check input files for generating pre-processed headers. + result = check_input_files(headerDir, sourceDir, verbose = args.verbose) + if result: + print "Fixing the input-files used for pre-processing of Boost.MPL headers IS required." + else: + print "Fixing the input-files used for pre-processing of Boost.MPL headers is NOT required." + else: + # Fix input files for generating pre-processed headers. + fix_input_files(headerDir, sourceDir, verbose = args.verbose) + + +if __name__ == '__main__': + main() diff --git a/src/boost/libs/mpl/preprocessed/include/bcc/user.hpp b/src/boost/libs/mpl/preprocessed/include/bcc/user.hpp new file mode 100644 index 00000000..97340b28 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/bcc/user.hpp @@ -0,0 +1,27 @@ + +// Copyright Aleksey Gurtovoy 2003-2008 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG + +#include <boost/preprocessor/config/config.hpp> + +#define BOOST_NO_TEMPLATE_TEMPLATES +#define BOOST_MPL_CFG_BCC590_WORKAROUNDS +#define BOOST_MPL_CFG_NO_BIND_TEMPLATE +#define BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC +#define BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES +#define BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES +#define BOOST_MPL_CFG_BROKEN_OVERLOAD_RESOLUTION +#define BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING +#define BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS +#define BOOST_MPL_CFG_NO_NESTED_FORWARDING diff --git a/src/boost/libs/mpl/preprocessed/include/bcc551/user.hpp b/src/boost/libs/mpl/preprocessed/include/bcc551/user.hpp new file mode 100644 index 00000000..eaa6fd9e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/bcc551/user.hpp @@ -0,0 +1,25 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG + +#include <boost/preprocessor/config/config.hpp> + +#define BOOST_NO_TEMPLATE_TEMPLATES +#define BOOST_MPL_CFG_NO_BIND_TEMPLATE +#define BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC +#define BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES +#define BOOST_MPL_CFG_BROKEN_OVERLOAD_RESOLUTION +#define BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING +#define BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS +#define BOOST_MPL_CFG_NO_NESTED_FORWARDING diff --git a/src/boost/libs/mpl/preprocessed/include/bcc_pre590/user.hpp b/src/boost/libs/mpl/preprocessed/include/bcc_pre590/user.hpp new file mode 100644 index 00000000..7cd1076d --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/bcc_pre590/user.hpp @@ -0,0 +1,26 @@ + +// Copyright Aleksey Gurtovoy 2003-2008 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Source$ +// $Date: 2004-09-14 07:39:55 -0500 (Tue, 14 Sep 2004) $ +// $Revision: 25084 $ + +#define BOOST_NO_CONFIG + +#include <boost/preprocessor/config/config.hpp> + +#define BOOST_NO_TEMPLATE_TEMPLATES +#define BOOST_MPL_CFG_NO_BIND_TEMPLATE +#define BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC +#define BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES +#define BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES +#define BOOST_MPL_CFG_BROKEN_OVERLOAD_RESOLUTION +#define BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING +#define BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS +#define BOOST_MPL_CFG_NO_NESTED_FORWARDING diff --git a/src/boost/libs/mpl/preprocessed/include/dmc/user.hpp b/src/boost/libs/mpl/preprocessed/include/dmc/user.hpp new file mode 100644 index 00000000..c0d92b14 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/dmc/user.hpp @@ -0,0 +1,15 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_MPL_CFG_DMC_AMBIGUOUS_CTPS diff --git a/src/boost/libs/mpl/preprocessed/include/gcc/user.hpp b/src/boost/libs/mpl/preprocessed/include/gcc/user.hpp new file mode 100644 index 00000000..6059dc3e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/gcc/user.hpp @@ -0,0 +1,15 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING diff --git a/src/boost/libs/mpl/preprocessed/include/mwcw/user.hpp b/src/boost/libs/mpl/preprocessed/include/mwcw/user.hpp new file mode 100644 index 00000000..0b74799e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/mwcw/user.hpp @@ -0,0 +1,15 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_MPL_CFG_BROKEN_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES diff --git a/src/boost/libs/mpl/preprocessed/include/no_ttp/user.hpp b/src/boost/libs/mpl/preprocessed/include/no_ttp/user.hpp new file mode 100644 index 00000000..d354bdf9 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/no_ttp/user.hpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_NO_TEMPLATE_TEMPLATES +#define BOOST_MPL_CFG_NO_NESTED_VALUE_ARITHMETIC diff --git a/src/boost/libs/mpl/preprocessed/include/plain/user.hpp b/src/boost/libs/mpl/preprocessed/include/plain/user.hpp new file mode 100644 index 00000000..a6ecf157 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/plain/user.hpp @@ -0,0 +1,15 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_MPL_AUX_LAMBDA_SUPPORT(unused1, unused2, unused3) diff --git a/src/boost/libs/mpl/preprocessed/include/typeof_based/user.hpp b/src/boost/libs/mpl/preprocessed/include/typeof_based/user.hpp new file mode 100644 index 00000000..36005bbd --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/include/typeof_based/user.hpp @@ -0,0 +1,15 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_NO_CONFIG +#define BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES diff --git a/src/boost/libs/mpl/preprocessed/list/list10.cpp b/src/boost/libs/mpl/preprocessed/list/list10.cpp new file mode 100644 index 00000000..1081c24f --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list10.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list10.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list10_c.cpp b/src/boost/libs/mpl/preprocessed/list/list10_c.cpp new file mode 100644 index 00000000..d61940a7 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list10_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list10_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list20.cpp b/src/boost/libs/mpl/preprocessed/list/list20.cpp new file mode 100644 index 00000000..ad11b3e8 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list20.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list20.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list20_c.cpp b/src/boost/libs/mpl/preprocessed/list/list20_c.cpp new file mode 100644 index 00000000..a9c93ae7 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list20_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list20_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list30.cpp b/src/boost/libs/mpl/preprocessed/list/list30.cpp new file mode 100644 index 00000000..8c16a647 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list30.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list30.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list30_c.cpp b/src/boost/libs/mpl/preprocessed/list/list30_c.cpp new file mode 100644 index 00000000..9d7539d3 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list30_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list30_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list40.cpp b/src/boost/libs/mpl/preprocessed/list/list40.cpp new file mode 100644 index 00000000..364fda28 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list40.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list40.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list40_c.cpp b/src/boost/libs/mpl/preprocessed/list/list40_c.cpp new file mode 100644 index 00000000..ceabeb98 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list40_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list40_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list50.cpp b/src/boost/libs/mpl/preprocessed/list/list50.cpp new file mode 100644 index 00000000..da35a615 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list50.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list50.hpp> diff --git a/src/boost/libs/mpl/preprocessed/list/list50_c.cpp b/src/boost/libs/mpl/preprocessed/list/list50_c.cpp new file mode 100644 index 00000000..f8d54ece --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/list/list50_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list/list50_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/map/map10.cpp b/src/boost/libs/mpl/preprocessed/map/map10.cpp new file mode 100644 index 00000000..4636ccd9 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/map/map10.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map/map10.hpp> diff --git a/src/boost/libs/mpl/preprocessed/map/map20.cpp b/src/boost/libs/mpl/preprocessed/map/map20.cpp new file mode 100644 index 00000000..d95a8b07 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/map/map20.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map/map20.hpp> diff --git a/src/boost/libs/mpl/preprocessed/map/map30.cpp b/src/boost/libs/mpl/preprocessed/map/map30.cpp new file mode 100644 index 00000000..487b9e0d --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/map/map30.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map/map30.hpp> diff --git a/src/boost/libs/mpl/preprocessed/map/map40.cpp b/src/boost/libs/mpl/preprocessed/map/map40.cpp new file mode 100644 index 00000000..748e5ad4 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/map/map40.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map/map40.hpp> diff --git a/src/boost/libs/mpl/preprocessed/map/map50.cpp b/src/boost/libs/mpl/preprocessed/map/map50.cpp new file mode 100644 index 00000000..261502ce --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/map/map50.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map/map50.hpp> diff --git a/src/boost/libs/mpl/preprocessed/pp.py b/src/boost/libs/mpl/preprocessed/pp.py new file mode 100644 index 00000000..24bfd27e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/pp.py @@ -0,0 +1,256 @@ + +# Copyright Aleksey Gurtovoy 2001-2004 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import fileinput +import os +import re +import string +import sys + +if_else = lambda a,b,c:(a and [b] or [c])[0] +max_len = 79 +ident = 4 + +def nearest_ident_pos(text): + return (len(text)/ident) * ident + +def block_format(limits, text, first_sep=' ', sep=',', need_last_ident=1 ): + if sep == ',' and string.find( text, '<' ) != -1: + sep = '%s ' % sep + + words = string.split( + string.join( string.split( text ), ' ' ) + , sep + ) + + s = ' ' * limits[0] + max_len = limits[1] + return '%s\n%s' \ + % ( + reduce( + lambda t,w,max_len=max_len,s=s,sep=sep: + if_else(t[1] + len(w) < max_len + , ('%s%s%s'% (t[0],t[2],w), t[1]+len(w)+len(t[2]), sep) + , ('%s\n%s%s%s'% (t[0],s,sep,w), len(s)+len(w)+len(sep), sep) + ) + , words + , (s,len(s)+len(first_sep),first_sep) + )[0] + , if_else(need_last_ident,s,'') + ) + +def handle_args( match ): + if re.compile('^\s*(typedef|struct|static)\s+.*?$').match(match.group(0)): + return match.group(0) + + return '%s'\ + % block_format( + (nearest_ident_pos(match.group(1)),max_len) + , match.group(3) + , match.group(2) + , ',' + , 0 + ) + + +def handle_inline_args(match): + if len(match.group(0)) < max_len: + return match.group(0) + + if match.group(9) == None: + return '%s%s<\n%s>\n'\ + % ( + match.group(1) + , match.group(3) + , block_format( + (nearest_ident_pos(match.group(1))+ident,max_len) + , match.group(4) + ) + ) + + return '%s%s<\n%s>\n%s%s'\ + % ( + match.group(1) + , match.group(3) + , block_format( + (nearest_ident_pos(match.group(1))+ident,max_len-len(match.group(9))) + , match.group(4) + ) + , string.replace(match.group(1),',',' ') + , match.group(9) + ) + +def handle_simple_list(match): + if match.group(1) == 'template': + return match.group(0) + + single_arg = re.compile('^\s*(\w|\d)+\s*$').match(match.group(2)) + return if_else(single_arg,'%s<%s>','%s< %s >') %\ + ( + match.group(1) + , string.join(string.split(match.group(2)), '') + ) + +def handle_static(match): + if len(match.group(0)) < max_len: + return match.group(0) + + (first_sep,sep) = if_else(string.find(match.group(0),'+') == -1, (' ',' '),(' ','+')) + return '%s%s\n%s%s' %\ + ( + match.group(1) + , string.join(string.split(match.group(2)), ' ') + , block_format( + (nearest_ident_pos(match.group(1))+ident,max_len) + , match.group(4) + , first_sep + , sep + ) + , match.group(5) + ) + +def handle_typedefs(match): + if string.count(match.group(2), ';') == 1: + return match.group(0) + + join_sep = ';\n%s' % match.group(1) + + return '%s%s\n' \ + % ( + match.group(1) + , string.join(map(string.strip, string.split(match.group(2), ';')), join_sep) + ) + +def fix_angle_brackets( match ): + return ' '.join( ''.join( match.group(1).split( ' ' ) ) ) + match.group(3) + + +class pretty: + def __init__(self, name): + self.output = open(name, "w") + self.prev_line = '' + + self.re_copyright_start = re.compile( r'^// Copyright .*$' ) + self.re_copyright_end = re.compile( r'^// See .* for documentation.$' ) + self.reading_copyright = 0 + self.copyright = None + + self.re_header_name_comment = re.compile( + r'^\s*//\s+\$[I]d:\s+(.*?%s\.hpp)\s+[^$]+[$]$' + % os.path.splitext( name )[0] + ) + + self.header_was_written = 0 + + self.re_junk = re.compile(r'^\s*(#|//[^/]|////).*$') + self.re_c_comment_start = re.compile(r'^\s*/\*.*') + self.re_c_comment_end = re.compile(r'^.*\*/\s*$') + self.inside_c_comment = 0 + + self.re_empty_line = re.compile(r'^\s*$') + self.re_comma = re.compile(r'(\S+)\s*,\s*') + self.re_assign = re.compile(r'(\S+[^<|^!|^>])\s*(=+)\s*(\S+)') + self.re_marked_empty_comment = re.compile(r'^\s*//\s*$') + self.re_typedef = re.compile(r'^\s+typedef\s+.*?;$') + self.re_nsl = re.compile(r'^(\s+typedef\s+.*?;|\s*(private|public):\s*|\s*{\s*|\s*(\w|\d|,)+\s*)$') + self.re_templ_decl = re.compile(r'^(\s*template\s*<\s*.*?|\s*(private|public):\s*)$') + self.re_type_const = re.compile(r'(const)\s+((unsigned|signed)?(bool|char|short|int|long))') + #self.re_templ_args = re.compile(r'^(\s*)(, | {2})((.*::.*?,?)+)\s*$') + self.re_templ_args = re.compile(r'^(\s*)(, | {2})((\s*(\w+)(\s+|::)\w+\s*.*?,?)+)\s*$') + self.re_inline_templ_args = re.compile( + r'^(\s+(,|:\s+)?|struct\s+)(\w+)\s*<((\s*(typename\s+)?\w+\s*(=\s*.*|<(\s*\w+\s*,?)+>\s*)?,?)+)\s*>\s+((struct|class).*?)?$' + ) + + self.re_simple_list = re.compile(r'(\w+)\s*<((\w|,| |-)+)>') + self.re_static_const = re.compile(r'(\s*)((BOOST_STATIC_CONSTANT\(\s*\w+,\s*|enum\s*\w*\s*{\s*)value\s*=)(.*?)([}|\)];)$') + self.re_typedefs = re.compile(r'(\s*)((\s*typedef\s*.*?;)+)\s*$') + self.re_fix_angle_brackets = re.compile( r'(>(\s*>)+)(,|\n$)' ) + self.re_closing_curly_brace = re.compile(r'^(}|struct\s+\w+);\s*$') + self.re_namespace_scope_templ = re.compile(r'^template\s*<\s*$') + self.re_namespace = re.compile(r'^\n?namespace\s+\w+\s*{\s*\n?$') + + def process(self, line): + if self.reading_copyright: + if not self.re_copyright_end.match( line ): + self.copyright += line + return + + self.reading_copyright = 0 + + if not self.header_was_written and self.re_copyright_start.match( line ): + self.copyright = line + self.reading_copyright = 1 + return + + # searching for header line + if not self.header_was_written: + if self.re_header_name_comment.match( line ): + self.header_was_written = 1 + match = self.re_header_name_comment.match( line ) + self.output.write( \ + '\n%s\n' \ + '// *Preprocessed* version of the main "%s" header\n' \ + '// -- DO NOT modify by hand!\n\n' \ + % ( self.copyright, match.group(1) ) + ) + return + + # skipping preprocessor directives, comments, etc. + if self.re_junk.match(line): + return + + if self.inside_c_comment or self.re_c_comment_start.match(line): + self.inside_c_comment = not self.re_c_comment_end.match(line) + return + + # restoring some empty lines + if self.re_templ_decl.match(line) and self.re_typedef.match(self.prev_line) \ + or not self.re_empty_line.match(line) and self.re_closing_curly_brace.match(self.prev_line) \ + or not self.re_empty_line.match(self.prev_line) \ + and ( self.re_namespace_scope_templ.match(line) \ + or self.re_namespace.match(line) and not self.re_namespace.match(self.prev_line) \ + ): + line = '\n%s' % line + + # removing excessive empty lines + if self.re_empty_line.match(line): + if self.re_empty_line.match(self.prev_line) or not self.header_was_written: + return + + # skip empty line after typedef + if self.re_nsl.match(self.prev_line): + return + + # formatting + line = self.re_comma.sub( r'\1, ', line ) + line = self.re_assign.sub( r'\1 \2 \3', line ) + line = self.re_marked_empty_comment.sub( r'\n', line ) + line = self.re_type_const.sub( r'\2 \1', line ) + line = self.re_templ_args.sub( handle_args, line ) + line = self.re_inline_templ_args.sub( handle_inline_args, line ) + line = self.re_simple_list.sub( handle_simple_list, line) + line = self.re_static_const.sub( handle_static, line ) + line = self.re_typedefs.sub( handle_typedefs, line ) + line = self.re_fix_angle_brackets.sub( fix_angle_brackets, line ) + + # write the output + self.output.write(line) + self.prev_line = line + +def main( src, dest ): + p = pretty( os.path.basename( dest ) ) + for line in fileinput.input( src ): + p.process(line) + +if __name__ == '__main__': + main( sys.argv[1], sys.argv[2] ) diff --git a/src/boost/libs/mpl/preprocessed/preprocess.cmd b/src/boost/libs/mpl/preprocessed/preprocess.cmd new file mode 100644 index 00000000..7fb92f37 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess.cmd @@ -0,0 +1 @@ +gcc -E -C -P "-I%(boost_root)s" "-D BOOST_USER_CONFIG=\"%(boost_root)s/libs/mpl/preprocessed/include/%(mode)s/user.hpp\"" -D BOOST_MPL_CFG_NO_OWN_PP_PRIMITIVES %(file)s >"%(file_path)s" diff --git a/src/boost/libs/mpl/preprocessed/preprocess.py b/src/boost/libs/mpl/preprocessed/preprocess.py new file mode 100644 index 00000000..0c38eb06 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess.py @@ -0,0 +1,88 @@ + +# Copyright Aleksey Gurtovoy 2001-2004 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import pp +import shutil +import os.path +import os +import string +import sys + +preprocess_cmd = open( "preprocess.cmd" ).readlines()[0] + +def process( file, boost_root, dst_dir, mode ): + file_path = "%s.hpp" % os.path.splitext( file )[0] + os.system( preprocess_cmd % { + 'boost_root': boost_root + , 'mode': mode + , 'file': file + , 'file_path': file_path + } ) + + os.rename( file_path, "%s.tmp" % file_path ) + pp.main( "%s.tmp" % file_path, file_path ) + os.remove( "%s.tmp" % file_path ) + + filename = os.path.basename(file_path) + dst_dir = os.path.join( dst_dir, mode ) + dst_file = os.path.join( dst_dir, filename ) + + if os.path.exists( dst_file ): + shutil.copymode( filename, dst_file ) + + shutil.copy( filename, dst_dir ) + os.remove( filename ) + + +def process_all( root, boost_root, dst_dir, mode ): + files = os.listdir( root ) + for file in files: + path = os.path.join( root, file ) + if os.path.splitext( file )[1] == ".cpp": + process( path, boost_root, dst_dir, mode ) + else: + if os.path.isdir( path ): + process_all( path, boost_root, dst_dir, mode ) + + +def main( all_modes, src_dir, dst_dir ): + if len( sys.argv ) < 2: + print "\nUsage:\n\t %s <mode> <boost_root> [<source_file>]" % os.path.basename( sys.argv[0] ) + print "\nPurpose:\n\t updates preprocessed version(s) of the header(s) in \"%s\" directory" % dst_dir + print "\nExample:\n\t the following command will re-generate and update all 'apply.hpp' headers:" + print "\n\t\t %s all f:\\cvs\\boost apply.cpp" % os.path.basename( sys.argv[0] ) + sys.exit( -1 ) + + if sys.argv[1] == "all": + modes = all_modes + else: + modes = [sys.argv[1]] + + boost_root = sys.argv[2] + dst_dir = os.path.join( boost_root, dst_dir ) + + for mode in modes: + if len( sys.argv ) > 3: + file = os.path.join( os.path.join( os.getcwd(), src_dir ), sys.argv[3] ) + process( file, boost_root, dst_dir, mode ) + else: + process_all( os.path.join( os.getcwd(), src_dir ), boost_root, dst_dir, mode ) + + +if __name__ == '__main__': + + main( + ["bcc", "bcc551", "gcc", "mwcw", "dmc", "no_ttp", "plain"] + , "src" + , os.path.join( "boost", "mpl", "aux_", "preprocessed" ) + ) diff --git a/src/boost/libs/mpl/preprocessed/preprocess_list.py b/src/boost/libs/mpl/preprocessed/preprocess_list.py new file mode 100644 index 00000000..ae172c26 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess_list.py @@ -0,0 +1,21 @@ + +# Copyright Aleksey Gurtovoy 2001-2006 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import preprocess +import os.path + +preprocess.main( + [ "plain" ] + , "list" + , os.path.join( "boost", "mpl", "list", "aux_", "preprocessed" ) + ) diff --git a/src/boost/libs/mpl/preprocessed/preprocess_map.py b/src/boost/libs/mpl/preprocessed/preprocess_map.py new file mode 100644 index 00000000..9f4fa9cc --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess_map.py @@ -0,0 +1,21 @@ + +# Copyright Aleksey Gurtovoy 2001-2006 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import preprocess +import os.path + +preprocess.main( + [ "plain", "typeof_based" ] + , "map" + , os.path.join( "boost", "mpl", "map", "aux_", "preprocessed" ) + ) diff --git a/src/boost/libs/mpl/preprocessed/preprocess_set.py b/src/boost/libs/mpl/preprocessed/preprocess_set.py new file mode 100644 index 00000000..9220a9b3 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess_set.py @@ -0,0 +1,21 @@ + +# Copyright Aleksey Gurtovoy 2001-2006 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import preprocess +import os.path + +preprocess.main( + [ "plain" ] + , "set" + , os.path.join( "boost", "mpl", "set", "aux_", "preprocessed" ) + ) diff --git a/src/boost/libs/mpl/preprocessed/preprocess_vector.py b/src/boost/libs/mpl/preprocessed/preprocess_vector.py new file mode 100644 index 00000000..26c65b6e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/preprocess_vector.py @@ -0,0 +1,21 @@ + +# Copyright Aleksey Gurtovoy 2001-2006 +# +# Distributed under 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) +# +# See http://www.boost.org/libs/mpl for documentation. + +# $Id$ +# $Date$ +# $Revision$ + +import preprocess +import os.path + +preprocess.main( + [ "plain", "typeof_based" ] + , "vector" + , os.path.join( "boost", "mpl", "vector", "aux_", "preprocessed" ) + ) diff --git a/src/boost/libs/mpl/preprocessed/set/set10.cpp b/src/boost/libs/mpl/preprocessed/set/set10.cpp new file mode 100644 index 00000000..20431d54 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set10.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set10.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set10_c.cpp b/src/boost/libs/mpl/preprocessed/set/set10_c.cpp new file mode 100644 index 00000000..1e862e0f --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set10_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set10_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set20.cpp b/src/boost/libs/mpl/preprocessed/set/set20.cpp new file mode 100644 index 00000000..49d9ff02 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set20.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set20.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set20_c.cpp b/src/boost/libs/mpl/preprocessed/set/set20_c.cpp new file mode 100644 index 00000000..056405f2 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set20_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set20_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set30.cpp b/src/boost/libs/mpl/preprocessed/set/set30.cpp new file mode 100644 index 00000000..c8b26659 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set30.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set30.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set30_c.cpp b/src/boost/libs/mpl/preprocessed/set/set30_c.cpp new file mode 100644 index 00000000..3134c232 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set30_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set30_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set40.cpp b/src/boost/libs/mpl/preprocessed/set/set40.cpp new file mode 100644 index 00000000..62bb1ef4 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set40.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set40.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set40_c.cpp b/src/boost/libs/mpl/preprocessed/set/set40_c.cpp new file mode 100644 index 00000000..081d8563 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set40_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set40_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set50.cpp b/src/boost/libs/mpl/preprocessed/set/set50.cpp new file mode 100644 index 00000000..6866664b --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set50.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set50.hpp> diff --git a/src/boost/libs/mpl/preprocessed/set/set50_c.cpp b/src/boost/libs/mpl/preprocessed/set/set50_c.cpp new file mode 100644 index 00000000..0ce79819 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/set/set50_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set/set50_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/advance_backward.cpp b/src/boost/libs/mpl/preprocessed/src/advance_backward.cpp new file mode 100644 index 00000000..d75aee74 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/advance_backward.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/advance_backward.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/advance_forward.cpp b/src/boost/libs/mpl/preprocessed/src/advance_forward.cpp new file mode 100644 index 00000000..0a8324ae --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/advance_forward.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/advance_forward.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/and.cpp b/src/boost/libs/mpl/preprocessed/src/and.cpp new file mode 100644 index 00000000..d44a8fd9 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/and.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/and.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/apply.cpp b/src/boost/libs/mpl/preprocessed/src/apply.cpp new file mode 100644 index 00000000..10d4aa7a --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/apply.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/apply.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/apply_fwd.cpp b/src/boost/libs/mpl/preprocessed/src/apply_fwd.cpp new file mode 100644 index 00000000..dca11749 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/apply_fwd.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/apply_fwd.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/apply_wrap.cpp b/src/boost/libs/mpl/preprocessed/src/apply_wrap.cpp new file mode 100644 index 00000000..41b737d6 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/apply_wrap.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/apply_wrap.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/arg.cpp b/src/boost/libs/mpl/preprocessed/src/arg.cpp new file mode 100644 index 00000000..d63b3ced --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/arg.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/arg.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/basic_bind.cpp b/src/boost/libs/mpl/preprocessed/src/basic_bind.cpp new file mode 100644 index 00000000..ebf063f2 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/basic_bind.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/basic_bind.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/bind.cpp b/src/boost/libs/mpl/preprocessed/src/bind.cpp new file mode 100644 index 00000000..8fb1537f --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/bind.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/bind.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/bind_fwd.cpp b/src/boost/libs/mpl/preprocessed/src/bind_fwd.cpp new file mode 100644 index 00000000..8ed1be13 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/bind_fwd.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/bind_fwd.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/bitand.cpp b/src/boost/libs/mpl/preprocessed/src/bitand.cpp new file mode 100644 index 00000000..25f1a725 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/bitand.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/bitand.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/bitor.cpp b/src/boost/libs/mpl/preprocessed/src/bitor.cpp new file mode 100644 index 00000000..09ec8160 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/bitor.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/bitor.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/bitxor.cpp b/src/boost/libs/mpl/preprocessed/src/bitxor.cpp new file mode 100644 index 00000000..1656c9f6 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/bitxor.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/bitxor.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/deque.cpp b/src/boost/libs/mpl/preprocessed/src/deque.cpp new file mode 100644 index 00000000..f0715193 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/deque.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/deque.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/divides.cpp b/src/boost/libs/mpl/preprocessed/src/divides.cpp new file mode 100644 index 00000000..cb59f281 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/divides.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/divides.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/equal_to.cpp b/src/boost/libs/mpl/preprocessed/src/equal_to.cpp new file mode 100644 index 00000000..5158e741 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/equal_to.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/equal_to.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/fold_impl.cpp b/src/boost/libs/mpl/preprocessed/src/fold_impl.cpp new file mode 100644 index 00000000..81cdcdda --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/fold_impl.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/fold_impl.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/full_lambda.cpp b/src/boost/libs/mpl/preprocessed/src/full_lambda.cpp new file mode 100644 index 00000000..e323cc6a --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/full_lambda.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/full_lambda.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/greater.cpp b/src/boost/libs/mpl/preprocessed/src/greater.cpp new file mode 100644 index 00000000..e344dac6 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/greater.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/greater.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/greater_equal.cpp b/src/boost/libs/mpl/preprocessed/src/greater_equal.cpp new file mode 100644 index 00000000..faf43704 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/greater_equal.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/greater_equal.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/inherit.cpp b/src/boost/libs/mpl/preprocessed/src/inherit.cpp new file mode 100644 index 00000000..b00c83f3 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/inherit.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/inherit.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/iter_fold_if_impl.cpp b/src/boost/libs/mpl/preprocessed/src/iter_fold_if_impl.cpp new file mode 100644 index 00000000..386f59f0 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/iter_fold_if_impl.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/iter_fold_if_impl.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/iter_fold_impl.cpp b/src/boost/libs/mpl/preprocessed/src/iter_fold_impl.cpp new file mode 100644 index 00000000..13cc36cd --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/iter_fold_impl.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/iter_fold_impl.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/lambda_no_ctps.cpp b/src/boost/libs/mpl/preprocessed/src/lambda_no_ctps.cpp new file mode 100644 index 00000000..9afc341a --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/lambda_no_ctps.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/lambda_no_ctps.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/less.cpp b/src/boost/libs/mpl/preprocessed/src/less.cpp new file mode 100644 index 00000000..b5eba3c1 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/less.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/less.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/less_equal.cpp b/src/boost/libs/mpl/preprocessed/src/less_equal.cpp new file mode 100644 index 00000000..a052119d --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/less_equal.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/less_equal.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/list.cpp b/src/boost/libs/mpl/preprocessed/src/list.cpp new file mode 100644 index 00000000..15908394 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/list.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/list_c.cpp b/src/boost/libs/mpl/preprocessed/src/list_c.cpp new file mode 100644 index 00000000..1fd93f2d --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/list_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/list_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/map.cpp b/src/boost/libs/mpl/preprocessed/src/map.cpp new file mode 100644 index 00000000..58872678 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/map.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/map.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/minus.cpp b/src/boost/libs/mpl/preprocessed/src/minus.cpp new file mode 100644 index 00000000..cdd65ef9 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/minus.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/minus.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/modulus.cpp b/src/boost/libs/mpl/preprocessed/src/modulus.cpp new file mode 100644 index 00000000..0eb0adf4 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/modulus.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/modulus.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/not_equal_to.cpp b/src/boost/libs/mpl/preprocessed/src/not_equal_to.cpp new file mode 100644 index 00000000..dffa86c7 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/not_equal_to.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/not_equal_to.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/or.cpp b/src/boost/libs/mpl/preprocessed/src/or.cpp new file mode 100644 index 00000000..d58ed510 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/or.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/or.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/placeholders.cpp b/src/boost/libs/mpl/preprocessed/src/placeholders.cpp new file mode 100644 index 00000000..4acd7f76 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/placeholders.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/placeholders.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/plus.cpp b/src/boost/libs/mpl/preprocessed/src/plus.cpp new file mode 100644 index 00000000..4b4b450e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/plus.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/plus.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/quote.cpp b/src/boost/libs/mpl/preprocessed/src/quote.cpp new file mode 100644 index 00000000..9cec2efa --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/quote.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/quote.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/reverse_fold_impl.cpp b/src/boost/libs/mpl/preprocessed/src/reverse_fold_impl.cpp new file mode 100644 index 00000000..cdd6b9f6 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/reverse_fold_impl.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/reverse_fold_impl.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/reverse_iter_fold_impl.cpp b/src/boost/libs/mpl/preprocessed/src/reverse_iter_fold_impl.cpp new file mode 100644 index 00000000..b3859d7e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/reverse_iter_fold_impl.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/reverse_iter_fold_impl.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/set.cpp b/src/boost/libs/mpl/preprocessed/src/set.cpp new file mode 100644 index 00000000..0984cc9a --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/set.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/set_c.cpp b/src/boost/libs/mpl/preprocessed/src/set_c.cpp new file mode 100644 index 00000000..3c1f6dbb --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/set_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/set_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/shift_left.cpp b/src/boost/libs/mpl/preprocessed/src/shift_left.cpp new file mode 100644 index 00000000..c0c3d0f8 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/shift_left.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/shift_left.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/shift_right.cpp b/src/boost/libs/mpl/preprocessed/src/shift_right.cpp new file mode 100644 index 00000000..16f3dbf2 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/shift_right.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/shift_right.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/template_arity.cpp b/src/boost/libs/mpl/preprocessed/src/template_arity.cpp new file mode 100644 index 00000000..eee7ba8b --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/template_arity.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/aux_/template_arity.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/times.cpp b/src/boost/libs/mpl/preprocessed/src/times.cpp new file mode 100644 index 00000000..122cfb0c --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/times.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/times.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/unpack_args.cpp b/src/boost/libs/mpl/preprocessed/src/unpack_args.cpp new file mode 100644 index 00000000..c3a62905 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/unpack_args.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/unpack_args.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/vector.cpp b/src/boost/libs/mpl/preprocessed/src/vector.cpp new file mode 100644 index 00000000..ab1104bf --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/vector.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector.hpp> diff --git a/src/boost/libs/mpl/preprocessed/src/vector_c.cpp b/src/boost/libs/mpl/preprocessed/src/vector_c.cpp new file mode 100644 index 00000000..1b3891cb --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/src/vector_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector10.cpp b/src/boost/libs/mpl/preprocessed/vector/vector10.cpp new file mode 100644 index 00000000..6276669e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector10.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector10.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector10_c.cpp b/src/boost/libs/mpl/preprocessed/vector/vector10_c.cpp new file mode 100644 index 00000000..f2c7a05a --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector10_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector10_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector20.cpp b/src/boost/libs/mpl/preprocessed/vector/vector20.cpp new file mode 100644 index 00000000..d8254087 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector20.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector20.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector20_c.cpp b/src/boost/libs/mpl/preprocessed/vector/vector20_c.cpp new file mode 100644 index 00000000..9c1c5314 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector20_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector20_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector30.cpp b/src/boost/libs/mpl/preprocessed/vector/vector30.cpp new file mode 100644 index 00000000..ccddd343 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector30.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector30.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector30_c.cpp b/src/boost/libs/mpl/preprocessed/vector/vector30_c.cpp new file mode 100644 index 00000000..7c43f8a7 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector30_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector30_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector40.cpp b/src/boost/libs/mpl/preprocessed/vector/vector40.cpp new file mode 100644 index 00000000..2584309e --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector40.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector40.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector40_c.cpp b/src/boost/libs/mpl/preprocessed/vector/vector40_c.cpp new file mode 100644 index 00000000..15a8608c --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector40_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector40_c.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector50.cpp b/src/boost/libs/mpl/preprocessed/vector/vector50.cpp new file mode 100644 index 00000000..dd577c9f --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector50.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector50.hpp> diff --git a/src/boost/libs/mpl/preprocessed/vector/vector50_c.cpp b/src/boost/libs/mpl/preprocessed/vector/vector50_c.cpp new file mode 100644 index 00000000..2acdbcc4 --- /dev/null +++ b/src/boost/libs/mpl/preprocessed/vector/vector50_c.cpp @@ -0,0 +1,16 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_PREPROCESSING_MODE +#include <boost/config.hpp> +#include <boost/mpl/vector/vector50_c.hpp> diff --git a/src/boost/libs/mpl/test/Jamfile.v2 b/src/boost/libs/mpl/test/Jamfile.v2 new file mode 100644 index 00000000..1c8f393d --- /dev/null +++ b/src/boost/libs/mpl/test/Jamfile.v2 @@ -0,0 +1,98 @@ + +compile aux_/increased_arity.cpp ; +compile aux_/largest_int.cpp ; +compile aux_/msvc_is_class.cpp ; +compile aux_/template_arity.cpp ; +compile aux_/preprocessor/is_seq.cpp ; +compile aux_/preprocessor/token_equal.cpp ; + +compile advance.cpp ; +compile always.cpp ; +compile apply.cpp ; +compile apply_wrap.cpp ; +compile arithmetic.cpp ; +compile as_sequence.cpp ; +compile assert.cpp ; +# link assert_vc8_p1.cpp assert_vc8_p2.cpp ; +compile at.cpp ; +compile back.cpp ; +compile bind.cpp ; +compile bitwise.cpp ; +run bool.cpp ; +compile comparison.cpp ; +compile contains.cpp ; +compile copy.cpp ; +compile copy_if.cpp ; +compile count.cpp ; +compile count_if.cpp ; +compile deque.cpp ; +compile distance.cpp ; +compile empty.cpp ; +compile equal.cpp ; +compile erase.cpp ; +compile erase_range.cpp ; +compile eval_if.cpp ; +compile filter_view.cpp ; +compile find.cpp ; +compile find_if.cpp ; +compile fold.cpp ; +run for_each.cpp ; +compile front.cpp ; +compile get_tag_def.cpp ; +compile has_xxx.cpp ; +compile identity.cpp ; +compile if.cpp ; +compile index_of.cpp ; +compile inherit.cpp ; +compile insert.cpp ; +compile insert_range.cpp ; +run int.cpp ; +run char.cpp ; +run integral_c.cpp : : : <toolset>vacpp:<cxxflags>-qchars=signed ; +compile is_placeholder.cpp ; +compile is_sequence.cpp ; +compile iterator_tags.cpp ; +compile joint_view.cpp ; +compile lambda.cpp ; +compile lambda_args.cpp ; +compile list.cpp ; +compile list_c.cpp ; +compile logical.cpp ; +compile lower_bound.cpp ; +compile map.cpp ; +compile max_element.cpp ; +compile min_max.cpp ; +compile multiset.cpp ; +compile next.cpp ; +compile no_has_xxx.cpp ; +compile numeric_ops.cpp ; +compile pair_view.cpp ; +compile partition.cpp ; +compile pop_front.cpp ; +compile push_back.cpp ; +compile push_front.cpp ; +compile quote.cpp ; +compile range_c.cpp ; +compile remove.cpp ; +compile remove_if.cpp ; +compile replace.cpp ; +compile replace_if.cpp ; +compile reverse.cpp ; +compile same_as.cpp ; +compile set.cpp ; +compile set_c.cpp ; +compile single_view.cpp ; +compile size.cpp ; +run size_t.cpp ; +compile sizeof.cpp ; +compile sort.cpp ; +compile stable_partition.cpp ; +compile transform.cpp ; +compile transform_view.cpp ; +compile unique.cpp ; +compile unpack_args.cpp ; +compile upper_bound.cpp ; +compile vector.cpp ; +compile vector_c.cpp ; +compile zip_view.cpp ; +run string.cpp ; diff --git a/src/boost/libs/mpl/test/advance.cpp b/src/boost/libs/mpl/test/advance.cpp new file mode 100644 index 00000000..e174ae4c --- /dev/null +++ b/src/boost/libs/mpl/test/advance.cpp @@ -0,0 +1,51 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/advance.hpp> +#include <boost/mpl/iterator_tags.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< int pos > struct iter +{ + typedef mpl::bidirectional_iterator_tag category; + typedef iter<(pos + 1)> next; + typedef iter<(pos - 1)> prior; + typedef int_<pos> type; +}; + +#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +namespace boost { namespace mpl { +template< int pos, typename Default > struct tag< iter<pos>,Default > : void_ {}; +}} +#endif + +typedef iter<0> first; +typedef iter<10> last; + +MPL_TEST_CASE() +{ + typedef mpl::advance<first,int_<10> >::type iter1; + typedef advance_c<first,10>::type iter2; + + MPL_ASSERT(( is_same<iter1, last> )); + MPL_ASSERT(( is_same<iter2, last> )); +} + +MPL_TEST_CASE() +{ + typedef mpl::advance<last,int_<-10> >::type iter1; + typedef advance_c<last,-10>::type iter2; + + MPL_ASSERT(( is_same<iter1, first> )); + MPL_ASSERT(( is_same<iter2, first> )); +} diff --git a/src/boost/libs/mpl/test/always.cpp b/src/boost/libs/mpl/test/always.cpp new file mode 100644 index 00000000..c879b973 --- /dev/null +++ b/src/boost/libs/mpl/test/always.cpp @@ -0,0 +1,48 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/apply.hpp> +#include <boost/mpl/always.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/int.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef always<true_> always_true; + + MPL_ASSERT(( apply< always_true > )); + MPL_ASSERT(( apply0< always_true > )); + MPL_ASSERT(( apply1< always_true,false_ > )); + MPL_ASSERT(( apply2< always_true,false_,false_ > )); + MPL_ASSERT(( apply3< always_true,false_,false_,false_ > )); +} + + +MPL_TEST_CASE() +{ + typedef always< int_<10> > always_10; + + typedef apply< always_10 >::type res; + typedef apply0< always_10 >::type res0; + typedef apply1< always_10,int_<0> >::type res1; + typedef apply2< always_10,int_<0>,int_<0> >::type res2; + typedef apply3< always_10,int_<0>,int_<0>,int_<0> >::type res3; + + MPL_ASSERT_RELATION( res::value, ==, 10 ); + MPL_ASSERT_RELATION( res0::value, ==, 10 ); + MPL_ASSERT_RELATION( res1::value, ==, 10 ); + MPL_ASSERT_RELATION( res2::value, ==, 10 ); + MPL_ASSERT_RELATION( res3::value, ==, 10 ); +} diff --git a/src/boost/libs/mpl/test/apply.cpp b/src/boost/libs/mpl/test/apply.cpp new file mode 100644 index 00000000..71bcbf9e --- /dev/null +++ b/src/boost/libs/mpl/test/apply.cpp @@ -0,0 +1,128 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/apply.hpp> +#include <boost/mpl/lambda.hpp> +#include <boost/mpl/plus.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + + +template< typename T > struct std_vector +{ +#if defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS) + typedef std_vector type; + BOOST_MPL_AUX_LAMBDA_SUPPORT(1, std_vector, (T)) +#endif +}; + + +MPL_TEST_CASE() +{ + typedef plus<int_<2>,int_<3> > plus1; + typedef lambda<plus1>::type plus2; + MPL_ASSERT(( is_same< plus1,plus2 > )); + + typedef lambda<std_vector<int> >::type v; + MPL_ASSERT(( is_same< v,std_vector<int> > )); + + typedef lambda<std_vector<_1> >::type make_vector; + typedef apply_wrap1<make_vector,int>::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector<int> > )); +} + +MPL_TEST_CASE() +{ + typedef plus<_1,_2> plus_fun; + typedef apply2<plus_fun,int_<2>,int_<3> >::type res; + + MPL_ASSERT_RELATION( res::value, ==, 5 ); +} + +MPL_TEST_CASE() +{ + typedef apply1<_1, plus<_1,_2> >::type plus_fun; + MPL_ASSERT(( is_same< plus_fun,plus<_1,_2> > )); + + typedef apply2<plus_fun,int_<2>,int_<3> >::type res; + MPL_ASSERT_RELATION( res::value, ==, 5 ); +} + +MPL_TEST_CASE() +{ + typedef lambda< lambda<_1> >::type make_lambda; + typedef apply_wrap1< make_lambda,std_vector<int> >::type v; + MPL_ASSERT(( is_same< v,std_vector<int> > )); + + typedef apply_wrap1< make_lambda,std_vector<_1> >::type make_vector; + typedef apply_wrap1< make_vector,int >::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector<int> > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< _1, std_vector<int> >::type v; + MPL_ASSERT(( is_same< v,std_vector<int> > )); + + typedef apply1< _1, std_vector<_1> >::type v_lambda; + typedef apply1<v_lambda,int>::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector<int> > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< lambda<_1>, std_vector<int> >::type v; + MPL_ASSERT(( is_same< v,std_vector<int> > )); + + typedef apply1< lambda<_1>, std_vector<_1> >::type make_vector; + typedef apply_wrap1< make_vector,int >::type v_int; + MPL_ASSERT(( is_same< v_int,std_vector<int> > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< lambda<_1>, plus<_1,_2> >::type plus_fun; + typedef apply_wrap2< plus_fun,int_<2>,int_<3> >::type res; + + MPL_ASSERT_RELATION( res::value, ==, 5 ); +} + +MPL_TEST_CASE() +{ + typedef bind2<plus<>,_1,_1> b1; + typedef lambda<b1>::type b2; + MPL_ASSERT(( is_same< b1,b2 > )); +} + +MPL_TEST_CASE() +{ +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) + typedef lambda< lambda< bind2<plus<>,_1,_1> > >::type make_lambda; + typedef apply_wrap1< make_lambda::type, int_<5> >::type res; + MPL_ASSERT_RELATION( res::value, ==, 10 ); +#endif +} + +MPL_TEST_CASE() +{ + typedef apply1< bind2<plus<>,_1,_1>, int_<5> >::type res; + MPL_ASSERT_RELATION( res::value, ==, 10 ); +} + +MPL_TEST_CASE() +{ + typedef apply1<_1, lambda<plus<_1,_2> > >::type plus_fun; + typedef apply_wrap2< plus_fun::type, int_<2>,int_<3> >::type res; + + MPL_ASSERT_RELATION( res::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/apply_wrap.cpp b/src/boost/libs/mpl/test/apply_wrap.cpp new file mode 100644 index 00000000..9c45f2e1 --- /dev/null +++ b/src/boost/libs/mpl/test/apply_wrap.cpp @@ -0,0 +1,121 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/apply_wrap.hpp> +#include <boost/mpl/limits/arity.hpp> +#include <boost/mpl/aux_/preprocessor/params.hpp> +#include <boost/mpl/aux_/preprocessor/enum.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/preprocessor/repeat.hpp> +#include <boost/preprocessor/comma_if.hpp> +#include <boost/preprocessor/dec.hpp> +#include <boost/preprocessor/if.hpp> +#include <boost/preprocessor/cat.hpp> + +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) +# define APPLY_0_FUNC_DEF(i) \ + struct f0 \ + { \ + template< typename T = int > struct apply { typedef char type; }; \ + }; \ +/**/ +#else +# define APPLY_0_FUNC_DEF(i) \ + struct f0 \ + { \ + template< typename T > struct apply { typedef char type; }; \ + }; \ +/**/ +#endif + +#define APPLY_N_FUNC_DEF(i) \ + struct first##i \ + { \ + template< BOOST_MPL_PP_PARAMS(i, typename U) > \ + struct apply { typedef U1 type; }; \ + }; \ + \ + struct last##i \ + { \ + template< BOOST_MPL_PP_PARAMS(i, typename U) > \ + struct apply { typedef BOOST_PP_CAT(U,i) type; }; \ + }; \ +/**/ + +#define APPLY_FUNC_DEF(z, i, unused) \ + BOOST_PP_IF( \ + i \ + , APPLY_N_FUNC_DEF \ + , APPLY_0_FUNC_DEF \ + )(i) \ +/**/ + +namespace { namespace test { + +BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , APPLY_FUNC_DEF + , unused + ) + +struct g0 { struct apply { typedef char type; }; }; + +}} + +#define APPLY_0_TEST(i, apply_) \ + typedef apply_<test::f##i>::type t; \ + { MPL_ASSERT(( boost::is_same<t, char> )); } \ +/**/ + +#define APPLY_N_TEST(i, apply_) \ + typedef apply_< \ + test::first##i \ + , char \ + BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \ + BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \ + >::type t1##i; \ + \ + typedef apply_< \ + test::last##i \ + , BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \ + BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \ + >::type t2##i; \ + { MPL_ASSERT(( boost::is_same<t1##i, char> )); } \ + { MPL_ASSERT(( boost::is_same<t2##i, char> )); } \ +/**/ + +#define APPLY_TEST(z, i, unused) \ + BOOST_PP_IF( \ + i \ + , APPLY_N_TEST \ + , APPLY_0_TEST \ + )(i, BOOST_PP_CAT(apply_wrap,i)) \ +/**/ + + +MPL_TEST_CASE() +{ + BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , APPLY_TEST + , unused + ) + +#if !defined(BOOST_MPL_CFG_NO_HAS_APPLY) + { + typedef apply_wrap0<test::g0>::type t; + MPL_ASSERT(( boost::is_same<t, char> )); + } +#endif +} diff --git a/src/boost/libs/mpl/test/arithmetic.cpp b/src/boost/libs/mpl/test/arithmetic.cpp new file mode 100644 index 00000000..81a615f1 --- /dev/null +++ b/src/boost/libs/mpl/test/arithmetic.cpp @@ -0,0 +1,50 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/arithmetic.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef int_<0> _0; + typedef int_<1> _1; + typedef int_<3> _3; + typedef int_<10> _10; + + MPL_ASSERT_RELATION( (plus<_0,_10>::value), ==, 10 ); + MPL_ASSERT_RELATION( (plus<_10,_0>::value), ==, 10 ); + + MPL_ASSERT_RELATION( (minus<_0,_10>::value), ==, -10 ); + MPL_ASSERT_RELATION( (minus<_10,_0>::value), ==, 10 ); + + MPL_ASSERT_RELATION( (times<_1,_10>::value), ==, 10 ); + MPL_ASSERT_RELATION( (times<_10,_1>::value), ==, 10 ); + MPL_ASSERT_RELATION( (multiplies<_1,_10>::value), ==, 10 ); + MPL_ASSERT_RELATION( (multiplies<_10,_1>::value), ==, 10 ); + + MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 ); + MPL_ASSERT_RELATION( (divides<_10,_1>::value), ==, 10 ); + + MPL_ASSERT_RELATION( (modulus<_10,_1>::value), ==, 0 ); + MPL_ASSERT_RELATION( (modulus<_10,_3>::value), ==, 1 ); + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) + MPL_ASSERT_RELATION( (minus<_10,_1,_10>::value), ==, -1 ); + MPL_ASSERT_RELATION( (plus<_10,_1,_10>::value), ==, 21 ); + MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 ); + MPL_ASSERT_RELATION( (divides<_10,_1,_10>::value), ==, 1 ); +#endif + + MPL_ASSERT_RELATION( negate<_10>::value, ==, -10 ); +} diff --git a/src/boost/libs/mpl/test/as_sequence.cpp b/src/boost/libs/mpl/test/as_sequence.cpp new file mode 100644 index 00000000..65edb5d1 --- /dev/null +++ b/src/boost/libs/mpl/test/as_sequence.cpp @@ -0,0 +1,23 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/as_sequence.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_sequence< as_sequence<int>::type > )); + MPL_ASSERT(( is_sequence< as_sequence<UDT>::type > )); + MPL_ASSERT(( is_sequence< as_sequence< vector<> >::type > )); +} diff --git a/src/boost/libs/mpl/test/assert.cpp b/src/boost/libs/mpl/test/assert.cpp new file mode 100644 index 00000000..b20f699d --- /dev/null +++ b/src/boost/libs/mpl/test/assert.cpp @@ -0,0 +1,101 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/assert.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_pointer.hpp> + + +BOOST_MPL_ASSERT(( boost::is_same<int,int> )); +BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); +BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); +BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); +BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); +BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () ); + +namespace my { +BOOST_MPL_ASSERT(( boost::is_same<int,int> )); +BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); +BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); +BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); +BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); +BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); +BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () ); +BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () ); +} + +template< typename T > +struct her +{ + BOOST_MPL_ASSERT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); + BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () ); +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) + BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) ); +#endif + + void f() + { + BOOST_MPL_ASSERT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +#endif + BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () ); +#if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) + BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) ); +#endif + } +}; + +template<class T> +struct nested : boost::mpl::true_ { + BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<void,T> )); + BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); +}; + +BOOST_MPL_ASSERT(( nested<int> )); +BOOST_MPL_ASSERT_NOT(( boost::mpl::not_<nested<unsigned> > )); + +int main() +{ + her<void> h; + h.f(); + + BOOST_MPL_ASSERT(( boost::is_same<int,int> )); + BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); + BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); + BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); + BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); + BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); + BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); + BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () ); + BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () ); + + return 0; +} diff --git a/src/boost/libs/mpl/test/assert_vc8.hpp b/src/boost/libs/mpl/test/assert_vc8.hpp new file mode 100644 index 00000000..f54df0e1 --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8.hpp @@ -0,0 +1,28 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include <boost/mpl/assert.hpp> + +template<class T> +bool func() +{ + BOOST_MPL_ASSERT_MSG( + true, + ALWAYS_TRUE, + (T)); + + return true; +} diff --git a/src/boost/libs/mpl/test/assert_vc8_p1.cpp b/src/boost/libs/mpl/test/assert_vc8_p1.cpp new file mode 100644 index 00000000..2883135a --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8_p1.cpp @@ -0,0 +1,23 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func<int>(); + +int main() +{ +} diff --git a/src/boost/libs/mpl/test/assert_vc8_p2.cpp b/src/boost/libs/mpl/test/assert_vc8_p2.cpp new file mode 100644 index 00000000..6b535734 --- /dev/null +++ b/src/boost/libs/mpl/test/assert_vc8_p2.cpp @@ -0,0 +1,19 @@ + +// Copyright Robin Linden 2018 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Part of a test to demonstrate a linking error with +// BOOST_MPL_ASSERT_MSG inside of functions under VC++8. + +#include "assert_vc8.hpp" + +static bool a = func<int>(); diff --git a/src/boost/libs/mpl/test/at.cpp b/src/boost/libs/mpl/test/at.cpp new file mode 100644 index 00000000..4b30edab --- /dev/null +++ b/src/boost/libs/mpl/test/at.cpp @@ -0,0 +1,39 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/at.hpp> +#include <boost/mpl/vector/vector10_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename Seq, int n > struct at_test +{ + typedef typename at_c<Seq,n>::type t; + MPL_ASSERT(( is_same< t, integral_c<int,9-n> > )); + MPL_ASSERT_RELATION( t::value, ==, 9 - n ); +}; + +MPL_TEST_CASE() +{ + typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> numbers; + + at_test< numbers, 0 >(); + at_test< numbers, 1 >(); + at_test< numbers, 2 >(); + at_test< numbers, 3 >(); + at_test< numbers, 4 >(); + at_test< numbers, 5 >(); + at_test< numbers, 6 >(); + at_test< numbers, 7 >(); + at_test< numbers, 8 >(); + at_test< numbers, 9 >(); +} diff --git a/src/boost/libs/mpl/test/aux_/increased_arity.cpp b/src/boost/libs/mpl/test/aux_/increased_arity.cpp new file mode 100644 index 00000000..47a433d6 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/increased_arity.cpp @@ -0,0 +1,50 @@ + +// Copyright Bruno Dutra 2015 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#define BOOST_MPL_LIMIT_METAFUNCTION_ARITY 15 +#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS + +#include <boost/mpl/logical.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/apply.hpp> + +#include <boost/mpl/aux_/test.hpp> + +#include <boost/preprocessor/inc.hpp> +#include <boost/preprocessor/repeat_from_to.hpp> +#include <boost/preprocessor/enum_params.hpp> +#include <boost/preprocessor/facilities/intercept.hpp> + +#define TEST_N_ARY(unused1, N, unused2) \ + static_assert_< \ + apply< \ + and_<BOOST_PP_ENUM_PARAMS(N, _ BOOST_PP_INTERCEPT)>, \ + BOOST_PP_ENUM_PARAMS(N, true_ BOOST_PP_INTERCEPT) \ + > \ + >(); \ +/**/ + +template<typename assertion> +void static_assert_(){ + MPL_ASSERT((typename assertion::type)); +} + +MPL_TEST_CASE() +{ + BOOST_PP_REPEAT_FROM_TO( + 2, + BOOST_PP_INC(BOOST_MPL_LIMIT_METAFUNCTION_ARITY), + TEST_N_ARY, + _ + ) +} diff --git a/src/boost/libs/mpl/test/aux_/largest_int.cpp b/src/boost/libs/mpl/test/aux_/largest_int.cpp new file mode 100644 index 00000000..d9a6fd34 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/largest_int.cpp @@ -0,0 +1,25 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/aux_/largest_int.hpp> +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,bool>::type, bool > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int<bool,char>::type, char > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int<char,bool>::type, char > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int<int,unsigned>::type, unsigned > )); + MPL_ASSERT(( is_same< mpl::aux::largest_int<unsigned,long>::type, long > )); +} diff --git a/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp b/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp new file mode 100644 index 00000000..6e5d49ea --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/msvc_is_class.cpp @@ -0,0 +1,46 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/aux_/config/msvc.hpp> +#include <boost/mpl/aux_/config/workaround.hpp> + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200) + +#include <boost/mpl/aux_/msvc_is_class.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename T > struct A { T x[0]; }; + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( aux::msvc_is_class< int > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< char > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< enum_ > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< char* > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< UDT* > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< UDT& > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete* > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< incomplete& > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< int[5] > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< void (*)() > )); + MPL_ASSERT_NOT(( aux::msvc_is_class< int (*)(int, char) > )); + + MPL_ASSERT(( aux::msvc_is_class< UDT > )); + MPL_ASSERT(( aux::msvc_is_class< incomplete > )); + MPL_ASSERT(( aux::msvc_is_class< abstract > )); + MPL_ASSERT(( aux::msvc_is_class< noncopyable > )); + MPL_ASSERT(( aux::msvc_is_class< A<int> > )); + MPL_ASSERT(( aux::msvc_is_class< A<incomplete> > )); +} + +#endif diff --git a/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp b/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp new file mode 100644 index 00000000..c860efc9 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/preprocessor/is_seq.cpp @@ -0,0 +1,33 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/aux_/preprocessor/is_seq.hpp> + +#include <boost/preprocessor/logical/not.hpp> +#include <boost/preprocessor/debug/assert.hpp> + +#define AUX_ASSERT_IS_SEQ( seq ) \ + BOOST_PP_ASSERT( BOOST_MPL_PP_IS_SEQ(seq) ) \ +/**/ + +#define AUX_ASSERT_IS_NOT_SEQ( seq ) \ + BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_IS_SEQ(seq) ) ) \ +/**/ + +#define SEQ (a)(b)(c) + +AUX_ASSERT_IS_NOT_SEQ( a ) +AUX_ASSERT_IS_SEQ( (a) ) +AUX_ASSERT_IS_SEQ( (a)(b) ) +AUX_ASSERT_IS_SEQ( (a)(b)(c) ) +AUX_ASSERT_IS_SEQ( SEQ ) diff --git a/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp b/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp new file mode 100644 index 00000000..442199a0 --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/preprocessor/token_equal.cpp @@ -0,0 +1,36 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/aux_/preprocessor/token_equal.hpp> + +#include <boost/preprocessor/logical/not.hpp> +#include <boost/preprocessor/debug/assert.hpp> + +#define AUX_ASSERT_EQUAL(x, y) \ + BOOST_PP_ASSERT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) \ +/**/ + +#define AUX_ASSERT_NOT_EQUAL(x, y) \ + BOOST_PP_ASSERT( BOOST_PP_NOT( BOOST_MPL_PP_TOKEN_EQUAL(x, y) ) ) \ +/**/ + +#define BOOST_MPL_PP_TOKEN_EQUAL_apple(x) x +#define BOOST_MPL_PP_TOKEN_EQUAL_orange(x) x + +AUX_ASSERT_NOT_EQUAL( apple, abc ) +AUX_ASSERT_NOT_EQUAL( abc, apple ) +AUX_ASSERT_NOT_EQUAL( apple, orange ) +AUX_ASSERT_NOT_EQUAL( orange, apple ) + +AUX_ASSERT_EQUAL( apple, apple ) +AUX_ASSERT_EQUAL( orange, orange ) diff --git a/src/boost/libs/mpl/test/aux_/template_arity.cpp b/src/boost/libs/mpl/test/aux_/template_arity.cpp new file mode 100644 index 00000000..22370d7c --- /dev/null +++ b/src/boost/libs/mpl/test/aux_/template_arity.cpp @@ -0,0 +1,31 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/aux_/template_arity.hpp> +#include <boost/mpl/aux_/test.hpp> + +#if defined(BOOST_EXTENDED_TEMPLATE_PARAMETERS_MATCHING) + +struct my {}; +template< typename T1 > struct my1 {}; +template< typename T1, typename T2 = void > struct my2 {}; + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (aux::template_arity<my>::value), ==, -1 ); + MPL_ASSERT_RELATION( (aux::template_arity< my1<int> >::value), ==, 1 ); + MPL_ASSERT_RELATION( (aux::template_arity< my2<int,long> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (aux::template_arity< my2<int> >::value), ==, 2 ); +} + +#endif diff --git a/src/boost/libs/mpl/test/back.cpp b/src/boost/libs/mpl/test/back.cpp new file mode 100644 index 00000000..84ae1e88 --- /dev/null +++ b/src/boost/libs/mpl/test/back.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/back.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename Seq, int value > struct back_test +{ + typedef typename back<Seq>::type t; + MPL_ASSERT_RELATION( t::value, ==, value ); +}; + +MPL_TEST_CASE() +{ + back_test< range_c<int,0,1>, 0 >(); + back_test< range_c<int,0,10>, 9 >(); + back_test< range_c<int,-10,0>, -1 >(); +} diff --git a/src/boost/libs/mpl/test/bind.cpp b/src/boost/libs/mpl/test/bind.cpp new file mode 100644 index 00000000..2a2de62c --- /dev/null +++ b/src/boost/libs/mpl/test/bind.cpp @@ -0,0 +1,89 @@ + +// Copyright Peter Dimov 2001-2002 +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/bind.hpp> +#include <boost/mpl/quote.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/next.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/apply_wrap.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_float.hpp> + +namespace { + +struct f1 +{ + template< typename T1 > struct apply + { + typedef T1 type; + }; +}; + +struct f5 +{ + template< typename T1, typename T2, typename T3, typename T4, typename T5 > + struct apply + { + typedef T5 type; + }; +}; + +} // namespace + +MPL_TEST_CASE() // basic argument binding +{ + typedef apply_wrap1< bind1<f1,_1>, int >::type r11; + typedef apply_wrap5< bind1<f1,_5>, void,void,void,void,int >::type r12; + MPL_ASSERT(( boost::is_same<r11,int> )); + MPL_ASSERT(( boost::is_same<r12,int> )); + + typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,_5>, void,void,void,void,int >::type r51; + typedef apply_wrap5< bind5<f5,_5,_4,_3,_2,_1>, int,void,void,void,void >::type r52; + MPL_ASSERT(( boost::is_same<r51,int> )); + MPL_ASSERT(( boost::is_same<r52,int> )); +} + + +MPL_TEST_CASE() // fully bound metafunction classes +{ + typedef apply_wrap0< bind1<f1,int> >::type r11; + typedef apply_wrap0< bind5<f5,void,void,void,void,int> >::type r51; + MPL_ASSERT(( boost::is_same<r11,int> )); + MPL_ASSERT(( boost::is_same<r51,int> )); +} + + +MPL_TEST_CASE() // metafunction class composition +{ + typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_1> >, int,void,void,void,void >::type r51; + typedef apply_wrap5< bind5<f5,_1,_2,_3,_4,bind1<f1,_5> >, void,void,void,void,int >::type r52; + MPL_ASSERT(( boost::is_same<r51,int> )); + MPL_ASSERT(( boost::is_same<r52,int> )); +} + +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ + && !defined(BOOST_MPL_CFG_NO_TEMPLATE_TEMPLATE_PARAMETERS) \ + && !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) +MPL_TEST_CASE() // if_ evaluation +{ + typedef bind3< quote3<if_>, _1, bind1< quote1<next>, _2>, _3 > f; + typedef apply_wrap3< f,true_,int_<0>,int >::type r1; + typedef apply_wrap3< f,false_,int,int_<0> >::type r2; + + MPL_ASSERT(( boost::is_same<r1,int_<1> > )); + MPL_ASSERT(( boost::is_same<r2,int_<0> > )); +} +#endif diff --git a/src/boost/libs/mpl/test/bitwise.cpp b/src/boost/libs/mpl/test/bitwise.cpp new file mode 100644 index 00000000..8e6e32bf --- /dev/null +++ b/src/boost/libs/mpl/test/bitwise.cpp @@ -0,0 +1,71 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// Copyright Jaap Suter 2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/bitwise.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +typedef integral_c<unsigned int, 0> _0; +typedef integral_c<unsigned int, 1> _1; +typedef integral_c<unsigned int, 2> _2; +typedef integral_c<unsigned int, 8> _8; +typedef integral_c<unsigned int, 0xffffffff> _ffffffff; + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (bitand_<_0,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitand_<_1,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitand_<_0,_1>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitand_<_0,_ffffffff>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitand_<_1,_ffffffff>::value), ==, 1 ); + MPL_ASSERT_RELATION( (bitand_<_8,_ffffffff>::value), ==, 8 ); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (bitor_<_0,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitor_<_1,_0>::value), ==, 1 ); + MPL_ASSERT_RELATION( (bitor_<_0,_1>::value), ==, 1 ); + MPL_ASSERT_RELATION( static_cast<long>(bitor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff) ); + MPL_ASSERT_RELATION( static_cast<long>(bitor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff) ); + MPL_ASSERT_RELATION( static_cast<long>(bitor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff) ); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (bitxor_<_0,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (bitxor_<_1,_0>::value), ==, 1 ); + MPL_ASSERT_RELATION( (bitxor_<_0,_1>::value), ==, 1 ); + MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_0,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 0) ); + MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_1,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 1) ); + MPL_ASSERT_RELATION( static_cast<long>(bitxor_<_8,_ffffffff>::value), ==, static_cast<long>(0xffffffff ^ 8) ); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (shift_right<_0,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (shift_right<_1,_0>::value), ==, 1 ); + MPL_ASSERT_RELATION( (shift_right<_1,_1>::value), ==, 0 ); + MPL_ASSERT_RELATION( (shift_right<_2,_1>::value), ==, 1 ); + MPL_ASSERT_RELATION( (shift_right<_8,_1>::value), ==, 4 ); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( (shift_left<_0,_0>::value), ==, 0 ); + MPL_ASSERT_RELATION( (shift_left<_1,_0>::value), ==, 1 ); + MPL_ASSERT_RELATION( (shift_left<_1,_1>::value), ==, 2 ); + MPL_ASSERT_RELATION( (shift_left<_2,_1>::value), ==, 4 ); + MPL_ASSERT_RELATION( (shift_left<_8,_1>::value), ==, 16 ); +} diff --git a/src/boost/libs/mpl/test/bool.cpp b/src/boost/libs/mpl/test/bool.cpp new file mode 100644 index 00000000..e023c0ca --- /dev/null +++ b/src/boost/libs/mpl/test/bool.cpp @@ -0,0 +1,38 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/bool.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <cassert> + +#if defined(BOOST_NO_CXX11_CONSTEXPR) +#define CONSTEXPR_BOOL_TEST(c) +#else +#define CONSTEXPR_BOOL_TEST(c) { static_assert(bool_<c>() == c, "Constexpr for bool_ failed"); } +#endif + +#define BOOL_TEST(c) \ + { MPL_ASSERT(( is_same< bool_<c>::value_type, bool > )); } \ + { MPL_ASSERT(( is_same< bool_<c>, c##_ > )); } \ + { MPL_ASSERT(( is_same< bool_<c>::type, bool_<c> > )); } \ + { MPL_ASSERT_RELATION( bool_<c>::value, ==, c ); } \ + CONSTEXPR_BOOL_TEST(c) \ + BOOST_TEST( bool_<c>() == c ); \ +/**/ + +MPL_TEST_CASE() +{ + BOOL_TEST(true) + BOOL_TEST(false) +} diff --git a/src/boost/libs/mpl/test/char.cpp b/src/boost/libs/mpl/test/char.cpp new file mode 100644 index 00000000..39f61e73 --- /dev/null +++ b/src/boost/libs/mpl/test/char.cpp @@ -0,0 +1,24 @@ + +// Copyright Eric Niebler 2008 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id: char.cpp 49240 2009-04-01 09:21:07Z eric_niebler $ +// $Date: 2009-04-01 02:21:07 -0700 (Wed, 1 Apr 2009) $ +// $Revision: 49240 $ + +#include <boost/mpl/char.hpp> +#include <boost/preprocessor/repeat.hpp> + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) char_<i> + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char) +} diff --git a/src/boost/libs/mpl/test/comparison.cpp b/src/boost/libs/mpl/test/comparison.cpp new file mode 100644 index 00000000..a59a1046 --- /dev/null +++ b/src/boost/libs/mpl/test/comparison.cpp @@ -0,0 +1,64 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/comparison.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +// make sure MSVC behaves nicely in presence of the following template +template< typename T > struct value {}; + +typedef int_<0> _0; +typedef int_<10> _10; + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( equal_to<_0, _10> )); + MPL_ASSERT_NOT(( equal_to<_10, _0> )); + MPL_ASSERT(( equal_to<_10, _10> )); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( not_equal_to<_0, _10> )); + MPL_ASSERT(( not_equal_to<_10, _0> )); + MPL_ASSERT_NOT(( not_equal_to<_10, _10> )); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( less<_0, _10> )); + MPL_ASSERT_NOT(( less<_10, _0> )); + MPL_ASSERT_NOT(( less<_10, _10> )); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( less_equal<_0, _10> )); + MPL_ASSERT_NOT(( less_equal<_10, _0> )); + MPL_ASSERT(( less_equal<_10, _10> )); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( greater<_10, _0> )); + MPL_ASSERT_NOT(( greater<_0, _10> )); + MPL_ASSERT_NOT(( greater<_10, _10> )); +} + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( greater_equal<_0, _10> )); + MPL_ASSERT(( greater_equal<_10, _0> )); + MPL_ASSERT(( greater_equal<_10, _10> )); +} diff --git a/src/boost/libs/mpl/test/contains.cpp b/src/boost/libs/mpl/test/contains.cpp new file mode 100644 index 00000000..1452a387 --- /dev/null +++ b/src/boost/libs/mpl/test/contains.cpp @@ -0,0 +1,24 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/contains.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef vector<int,char,long,short,char,long,double,long>::type types; + + MPL_ASSERT(( contains< types,short > )); + MPL_ASSERT_NOT(( contains< types,unsigned > )); +} diff --git a/src/boost/libs/mpl/test/copy.cpp b/src/boost/libs/mpl/test/copy.cpp new file mode 100644 index 00000000..a776f55c --- /dev/null +++ b/src/boost/libs/mpl/test/copy.cpp @@ -0,0 +1,211 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/copy.hpp> + +#include <boost/mpl/vector/vector20_c.hpp> +#include <boost/mpl/vector/vector0.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/front_inserter.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/less.hpp> + +#include <boost/mpl/begin_end_fwd.hpp> +#include <boost/mpl/size_fwd.hpp> +#include <boost/mpl/empty_fwd.hpp> +#include <boost/mpl/front_fwd.hpp> +#include <boost/mpl/insert_fwd.hpp> +#include <boost/mpl/insert_range_fwd.hpp> +#include <boost/mpl/erase_fwd.hpp> +#include <boost/mpl/clear_fwd.hpp> +#include <boost/mpl/push_back_fwd.hpp> +#include <boost/mpl/pop_back_fwd.hpp> +#include <boost/mpl/back_fwd.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef vector10_c<int,9,8,7,6,5,4,3,2,1,0> answer; + typedef copy< + range_c<int,0,10> + , mpl::front_inserter< vector0<> > + >::type result; + + MPL_ASSERT_RELATION( size<result>::value, ==, 10 ); + MPL_ASSERT(( equal< result,answer > )); +} + +MPL_TEST_CASE() +{ + typedef vector10_c<int,10,11,12,13,14,15,16,17,18,19> numbers; + typedef reverse_copy< + range_c<int,0,10> + , mpl::front_inserter<numbers> + >::type result; + + MPL_ASSERT_RELATION( size<result>::value, ==, 20 ); + MPL_ASSERT(( equal< result,range_c<int,0,20> > )); +} + +struct push_back_only_tag {}; + +template< typename Seq > +struct push_back_only +{ + typedef push_back_only_tag tag; + typedef Seq seq; +}; + +namespace boost { namespace mpl { + +template<> +struct begin_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : begin< typename Seq::seq > + { + }; +}; + +template<> +struct end_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : end< typename Seq::seq > + { + }; +}; + +template<> +struct size_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : size< typename Seq::seq > + { + }; +}; + +template<> +struct empty_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : empty< typename Seq::seq > + { + }; +}; + +template<> +struct front_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : front< typename Seq::seq > + { + }; +}; + +template<> +struct insert_impl< ::push_back_only_tag > +{ + template< typename Seq, typename Pos, typename X > struct apply + { + typedef ::push_back_only< + typename insert< typename Seq::seq, Pos, X >::type + > type; + }; +}; + +template<> +struct insert_range_impl< ::push_back_only_tag > +{ + template< typename Seq, typename Pos, typename X > struct apply + { + typedef ::push_back_only< + typename insert_range< typename Seq::seq, Pos, X >::type + > type; + }; +}; + +template<> +struct erase_impl< ::push_back_only_tag > +{ + template< typename Seq, typename Iter1, typename Iter2 > struct apply + { + typedef ::push_back_only< + typename erase< typename Seq::seq, Iter1, Iter2 >::type + > type; + }; +}; + +template<> +struct clear_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + { + typedef ::push_back_only< + typename clear< typename Seq::seq >::type + > type; + }; +}; + +template<> +struct push_back_impl< ::push_back_only_tag > +{ + template< typename Seq, typename X > struct apply + { + typedef ::push_back_only< + typename push_back< typename Seq::seq, X >::type + > type; + }; +}; + +template<> +struct pop_back_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + { + typedef ::push_back_only< + typename pop_back< typename Seq::seq >::type + > type; + }; +}; + +template<> +struct back_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : back< typename Seq::seq > + { + }; +}; + +template<> +struct has_push_back_impl< ::push_back_only_tag > +{ + template< typename Seq > struct apply + : less< size<Seq>,int_<10> > + { + }; +}; + +}} + +MPL_TEST_CASE() +{ + typedef vector10_c<int,0,1,2,3,4,5,6,7,8,9> numbers; + typedef copy< push_back_only< numbers > >::type result; + + MPL_ASSERT((equal< numbers, result >)); +} diff --git a/src/boost/libs/mpl/test/copy_if.cpp b/src/boost/libs/mpl/test/copy_if.cpp new file mode 100644 index 00000000..698b4d7a --- /dev/null +++ b/src/boost/libs/mpl/test/copy_if.cpp @@ -0,0 +1,54 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/copy_if.hpp> +#include <boost/mpl/list/list10_c.hpp> +#include <boost/mpl/list/list10.hpp> +#include <boost/mpl/front_inserter.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/size.hpp> +#include <boost/type_traits/is_float.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list10_c<int,0,1,2,3,4,5,6,7,8,9>::type numbers; + typedef list5_c<int,4,3,2,1,0>::type answer; + typedef copy_if< + numbers + , less<_,int_<5> > + , mpl::front_inserter< list0_c<int> > + >::type result; + + MPL_ASSERT_RELATION(size<result>::value, ==, 5); + MPL_ASSERT(( equal<result,answer> )); +} + + +MPL_TEST_CASE() +{ + typedef list8<int,float,long,float,char,long,double,double>::type types; + typedef list4<float,float,double,double>::type float_types; + typedef reverse_copy_if< + types + , is_float<_> + , mpl::front_inserter< list0<> > + >::type result; + + MPL_ASSERT_RELATION(mpl::size<result>::value, ==, 4); + MPL_ASSERT(( equal<result,float_types> )); +} diff --git a/src/boost/libs/mpl/test/count.cpp b/src/boost/libs/mpl/test/count.cpp new file mode 100644 index 00000000..7d96fee3 --- /dev/null +++ b/src/boost/libs/mpl/test/count.cpp @@ -0,0 +1,41 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/count.hpp> + +#include <boost/mpl/vector.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef vector<int,char,long,short,char,long,double,long> types; + + MPL_ASSERT_RELATION( (count<types,int>::value), ==, 1 ); + MPL_ASSERT_RELATION( (count<types,double>::value), ==, 1 ); + MPL_ASSERT_RELATION( (count<types,char>::value), ==, 2 ); + MPL_ASSERT_RELATION( (count<types,long>::value), ==, 3 ); + MPL_ASSERT_RELATION( (count<types,unsigned>::value), ==, 0 ); +} + +MPL_TEST_CASE() +{ + typedef vector_c<int,1,0,5,1,7,5,0,5> values; + + MPL_ASSERT_RELATION( (count< values, integral_c<int,1> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count< values, integral_c<int,0> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count< values, integral_c<int,5> >::value), ==, 3 ); + MPL_ASSERT_RELATION( (count< values, integral_c<int,7> >::value), ==, 1 ); + MPL_ASSERT_RELATION( (count< values, integral_c<int,8> >::value), ==, 0 ); +} diff --git a/src/boost/libs/mpl/test/count_if.cpp b/src/boost/libs/mpl/test/count_if.cpp new file mode 100644 index 00000000..598ffeeb --- /dev/null +++ b/src/boost/libs/mpl/test/count_if.cpp @@ -0,0 +1,36 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/count_if.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/comparison.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_float.hpp> +#include <boost/type_traits/is_same.hpp> + +MPL_TEST_CASE() +{ + typedef vector<int,char&,long,short,char&,long,double,long> types; + typedef vector_c<int,1,0,5,1,7,5,0,5> values; + + MPL_ASSERT_RELATION( (count_if< types, boost::is_float<_> >::value), ==, 1 ); + MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,char&> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count_if< types, boost::is_same<_,void*> >::value), ==, 0 ); + + MPL_ASSERT_RELATION( (count_if< values, less<_,int_<5> > >::value), ==, 4 ); + MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<0>,_> >::value), ==, 2 ); + MPL_ASSERT_RELATION( (count_if< values, equal_to<int_<-1>,_> >::value), ==, 0 ); +} diff --git a/src/boost/libs/mpl/test/deque.cpp b/src/boost/libs/mpl/test/deque.cpp new file mode 100644 index 00000000..4ac747cd --- /dev/null +++ b/src/boost/libs/mpl/test/deque.cpp @@ -0,0 +1,92 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/deque.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/pop_back.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/back.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/empty.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef deque<> d0; + typedef deque<char> d1; + typedef deque<char,long> d2; + typedef deque<char,char,char,char,char,char,char,char,int> d9; + + MPL_ASSERT_RELATION( size<d0>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<d1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<d2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<d9>::value, ==, 9 ); + + MPL_ASSERT(( empty<d0> )); + MPL_ASSERT_NOT(( empty<d1> )); + MPL_ASSERT_NOT(( empty<d2> )); + MPL_ASSERT_NOT(( empty<d9> )); + + MPL_ASSERT(( is_same< front<d1>::type,char > )); + MPL_ASSERT(( is_same< back<d1>::type,char > )); + MPL_ASSERT(( is_same< front<d2>::type,char > )); + MPL_ASSERT(( is_same< back<d2>::type,long > )); + MPL_ASSERT(( is_same< front<d9>::type,char > )); + MPL_ASSERT(( is_same< back<d9>::type,int > )); +} + + +MPL_TEST_CASE() +{ + typedef deque<char,long> d2; + + typedef begin<d2>::type i1; + typedef next<i1>::type i2; + typedef next<i2>::type i3; + + MPL_ASSERT(( is_same<deref<i1>::type,char> )); + MPL_ASSERT(( is_same<deref<i2>::type,long> )); + MPL_ASSERT(( is_same< i3, end<d2>::type > )); +} + +MPL_TEST_CASE() +{ + typedef deque<> d0; + + typedef push_back<d0,int>::type d1; + MPL_ASSERT(( is_same< back<d1>::type,int > )); + + typedef push_front<d1,char>::type d2; + MPL_ASSERT(( is_same< back<d2>::type,int > )); + MPL_ASSERT(( is_same< front<d2>::type,char > )); + + typedef push_back<d2,long>::type d3; + MPL_ASSERT(( is_same< back<d3>::type,long > )); +} + +MPL_TEST_CASE() +{ + typedef deque<> d0; + typedef deque<char> d1; + typedef deque<char,long> d2; + typedef deque<char,char,char,char,char,char,char,char,int> d9; + + MPL_ASSERT_RELATION( size<d0>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<d1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<d2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<d9>::value, ==, 9 ); +} diff --git a/src/boost/libs/mpl/test/distance.cpp b/src/boost/libs/mpl/test/distance.cpp new file mode 100644 index 00000000..879dd53e --- /dev/null +++ b/src/boost/libs/mpl/test/distance.cpp @@ -0,0 +1,37 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/distance.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/range_c.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef list<char,short,int,long>::type list; + typedef begin<list>::type first; + typedef end<list>::type last; + + MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 4 ); +} + +MPL_TEST_CASE() +{ + typedef range_c<int,0,10>::type range; + typedef begin<range>::type first; + typedef end<range>::type last; + + MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 10 ); +} diff --git a/src/boost/libs/mpl/test/empty.cpp b/src/boost/libs/mpl/test/empty.cpp new file mode 100644 index 00000000..7e73b361 --- /dev/null +++ b/src/boost/libs/mpl/test/empty.cpp @@ -0,0 +1,23 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/empty.hpp> + +#include <boost/mpl/list/list10.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + MPL_ASSERT(( empty< list0<> > )); + MPL_ASSERT_NOT(( empty< list1<char> > )); +} diff --git a/src/boost/libs/mpl/test/empty_sequence.cpp b/src/boost/libs/mpl/test/empty_sequence.cpp new file mode 100644 index 00000000..2fa989fa --- /dev/null +++ b/src/boost/libs/mpl/test/empty_sequence.cpp @@ -0,0 +1,39 @@ + +// Copyright Aleksey Gurtovoy 2004 +// Copyright Alexander Nasonov 2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/empty_sequence.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/advance.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/add_pointer.hpp> + +MPL_TEST_CASE() +{ + typedef begin<empty_sequence>::type begin; + typedef end<empty_sequence>::type end; + + MPL_ASSERT(( is_same<begin,end> )); + MPL_ASSERT_RELATION( (mpl::distance<begin,end>::value), ==, 0 ); + MPL_ASSERT_RELATION( size<empty_sequence>::value, ==, 0 ); + + typedef advance_c<begin,0>::type advanced; + MPL_ASSERT(( is_same<advanced,end> )); + + MPL_ASSERT(( equal< empty_sequence, empty_sequence::type > )); +} diff --git a/src/boost/libs/mpl/test/equal.cpp b/src/boost/libs/mpl/test/equal.cpp new file mode 100644 index 00000000..19390efe --- /dev/null +++ b/src/boost/libs/mpl/test/equal.cpp @@ -0,0 +1,31 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/equal.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,float,long,double,char,long,double,float> list1; + typedef list<int,float,long,double,char,long,double,float> list2; + typedef list<int,float,long,double,char,long,double,short> list3; + typedef list<int,float,long,double,char,long,double> list4; + + MPL_ASSERT(( equal<list1,list2> )); + MPL_ASSERT(( equal<list2,list1> )); + MPL_ASSERT_NOT(( equal<list2,list3> )); + MPL_ASSERT_NOT(( equal<list3,list4> )); + MPL_ASSERT_NOT(( equal<list4,list3> )); +} diff --git a/src/boost/libs/mpl/test/erase.cpp b/src/boost/libs/mpl/test/erase.cpp new file mode 100644 index 00000000..ca5b411b --- /dev/null +++ b/src/boost/libs/mpl/test/erase.cpp @@ -0,0 +1,45 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/erase.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/find.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/integral_c.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,char,long,short,char,long,double,long> types; + typedef find<types,short>::type iter; + + typedef erase<types, iter>::type result; + MPL_ASSERT_RELATION( size<result>::value, ==, 7 ); + + typedef find<result,short>::type result_iter; + MPL_ASSERT(( is_same< result_iter, end<result>::type > )); +} + +MPL_TEST_CASE() +{ + typedef list_c<int,1,0,5,1,7,5,0,5> values; + typedef find< values, integral_c<int,7> >::type iter; + + typedef erase<values, iter>::type result; + MPL_ASSERT_RELATION( size<result>::value, ==, 7 ); + + typedef find<result, integral_c<int,7> >::type result_iter; + MPL_ASSERT(( is_same< result_iter, end<result>::type > )); +} diff --git a/src/boost/libs/mpl/test/erase_range.cpp b/src/boost/libs/mpl/test/erase_range.cpp new file mode 100644 index 00000000..5e14c819 --- /dev/null +++ b/src/boost/libs/mpl/test/erase_range.cpp @@ -0,0 +1,34 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/erase.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/find.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,char,long,short,unsigned,long,double,long> types; + + typedef find<types,short>::type iter1; + typedef find<types,double>::type iter2; + + typedef erase<types,iter1,iter2>::type result; + + MPL_ASSERT_RELATION( size<result>::value, ==, 5 ); + + typedef find<result,unsigned>::type iter; + MPL_ASSERT(( is_same< iter, end<result>::type > )); +} diff --git a/src/boost/libs/mpl/test/eval_if.cpp b/src/boost/libs/mpl/test/eval_if.cpp new file mode 100644 index 00000000..e2b4332c --- /dev/null +++ b/src/boost/libs/mpl/test/eval_if.cpp @@ -0,0 +1,33 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/identity.hpp> + +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_same.hpp> + +MPL_TEST_CASE() +{ + typedef eval_if< true_, identity<char>, identity<long> >::type t1; + typedef eval_if_c< true, identity<char>, identity<long> >::type t2; + typedef eval_if< false_, identity<char>, identity<long> >::type t3; + typedef eval_if_c< false, identity<char>, identity<long> >::type t4; + + MPL_ASSERT(( is_same<t1,char> )); + MPL_ASSERT(( is_same<t2,char> )); + MPL_ASSERT(( is_same<t3,long> )); + MPL_ASSERT(( is_same<t4,long> )); +} diff --git a/src/boost/libs/mpl/test/filter_view.cpp b/src/boost/libs/mpl/test/filter_view.cpp new file mode 100644 index 00000000..2ae57540 --- /dev/null +++ b/src/boost/libs/mpl/test/filter_view.cpp @@ -0,0 +1,42 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/static_assert.hpp> +#include <boost/mpl/filter_view.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/max_element.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/sizeof.hpp> +#include <boost/mpl/deref.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_float.hpp> +#include <boost/type_traits/is_same.hpp> + +MPL_TEST_CASE() +{ + typedef mpl::list<int,float,long,float,char[50],long double,char> types; + typedef mpl::list<float,float,long double> floats; + + MPL_ASSERT(( equal< mpl::filter_view< types,boost::is_float<_> >::type,floats > )); + + typedef mpl::max_element< + mpl::transform_view< + mpl::filter_view< types,boost::is_float<_> > + , mpl::sizeof_<_> + > + >::type iter; + + MPL_ASSERT((is_same<mpl::deref<iter::base>::type, long double>)); +} diff --git a/src/boost/libs/mpl/test/find.cpp b/src/boost/libs/mpl/test/find.cpp new file mode 100644 index 00000000..a45d5216 --- /dev/null +++ b/src/boost/libs/mpl/test/find.cpp @@ -0,0 +1,37 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/find.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,char,long,short,char,long,double,long>::type types; + typedef list_c<int,1,0,5,1,7,5,0,5> values; + + typedef find<types, short>::type types_iter; + typedef find< values, integral_c<int,7> >::type values_iter; + + MPL_ASSERT(( is_same< deref<types_iter>::type, short> )); + MPL_ASSERT_RELATION( deref<values_iter>::type::value, ==, 7 ); + + typedef begin<types>::type types_first; + typedef begin<values>::type values_first; + MPL_ASSERT_RELATION( (mpl::distance< types_first,types_iter >::value), ==, 3 ); + MPL_ASSERT_RELATION( (mpl::distance< values_first,values_iter >::value), ==, 4 ); +} diff --git a/src/boost/libs/mpl/test/find_if.cpp b/src/boost/libs/mpl/test/find_if.cpp new file mode 100644 index 00000000..0d0ce89e --- /dev/null +++ b/src/boost/libs/mpl/test/find_if.cpp @@ -0,0 +1,46 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/find_if.hpp> + +#include <boost/mpl/vector.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_float.hpp> +#include <boost/type_traits/is_same.hpp> + +typedef vector<int,char,long,short,char,long,double,float,char>::type types; +typedef begin<types>::type first_; + +MPL_TEST_CASE() +{ + typedef find_if< types, boost::is_float<_> >::type iter; + MPL_ASSERT(( is_same< iter::type, double > )); + MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 6 ); +} + +MPL_TEST_CASE() +{ + typedef find_if< types, boost::is_same<_,long> >::type iter; + MPL_ASSERT(( is_same< iter::type, long > )); + MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 2 ); +} + +MPL_TEST_CASE() +{ + typedef find_if< types, boost::is_same<_,void> >::type iter; + MPL_ASSERT(( is_same< iter, end<types>::type > )); + MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, size<types>::value ); +} diff --git a/src/boost/libs/mpl/test/fold.cpp b/src/boost/libs/mpl/test/fold.cpp new file mode 100644 index 00000000..48f47587 --- /dev/null +++ b/src/boost/libs/mpl/test/fold.cpp @@ -0,0 +1,55 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/fold.hpp> +#include <boost/mpl/reverse_fold.hpp> +//#include <boost/mpl/vector.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/next.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/size.hpp> +#include <boost/type_traits/is_float.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<long,float,short,double,float,long,long double> types; + typedef fold< + types + , int_<0> + , if_< boost::is_float<_2>,next<_1>,_1 > + >::type number_of_floats; + + MPL_ASSERT_RELATION( number_of_floats::value, ==, 4 ); +} + +MPL_TEST_CASE() +{ + typedef list_c<int,5,-1,0,-7,-2,0,-5,4> numbers; + typedef list_c<int,-1,-7,-2,-5> negatives; + typedef reverse_fold< + numbers + , list_c<int> + , if_< less< _2,int_<0> >, push_front<_1,_2>, _1 > + >::type result; + + MPL_ASSERT(( equal< result,negatives,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/for_each.cpp b/src/boost/libs/mpl/test/for_each.cpp new file mode 100644 index 00000000..ec7a3d50 --- /dev/null +++ b/src/boost/libs/mpl/test/for_each.cpp @@ -0,0 +1,81 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/for_each.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/lambda.hpp> +#include <boost/bind.hpp> + +#include <vector> +#include <iostream> +#include <algorithm> +#include <typeinfo> +#include <cassert> + +namespace mpl = boost::mpl; + +struct type_printer +{ + type_printer(std::ostream& s) : f_stream(&s) {} + template< typename U > void operator()(mpl::identity<U>) + { + *f_stream << typeid(U).name() << '\n'; + } + + private: + std::ostream* f_stream; +}; + +struct value_printer +{ + value_printer(std::ostream& s) : f_stream(&s) {} + template< typename U > void operator()(U x) + { + *f_stream << x << '\n'; + } + + private: + std::ostream* f_stream; +}; + +#ifdef __ICL +# pragma warning(disable:985) +#endif + +void push_back(std::vector<int>* c, int i) +{ + c->push_back(i); +} + +int main() +{ + typedef mpl::list<char,short,int,long,float,double> types; + mpl::for_each< types,mpl::make_identity<mpl::_1> >(type_printer(std::cout)); + + typedef mpl::range_c<int,0,10> numbers; + std::vector<int> v; + + mpl::for_each<numbers>( + boost::bind(&push_back, &v, _1) + ); + + mpl::for_each< numbers >(value_printer(std::cout)); + + for (unsigned i = 0; i < v.size(); ++i) + assert(v[i] == (int)i); + + return 0; +} diff --git a/src/boost/libs/mpl/test/front.cpp b/src/boost/libs/mpl/test/front.cpp new file mode 100644 index 00000000..b28dffed --- /dev/null +++ b/src/boost/libs/mpl/test/front.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/front.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename Seq, int value > struct front_test +{ + typedef typename front<Seq>::type t; + MPL_ASSERT_RELATION( t::value, ==, value ); +}; + +MPL_TEST_CASE() +{ + front_test< range_c<int,1,10>, 1 >(); + front_test< range_c<int,2,10>, 2 >(); + front_test< range_c<int,-1,0>, -1 >(); +} diff --git a/src/boost/libs/mpl/test/get_tag_def.cpp b/src/boost/libs/mpl/test/get_tag_def.cpp new file mode 100644 index 00000000..eb160dd8 --- /dev/null +++ b/src/boost/libs/mpl/test/get_tag_def.cpp @@ -0,0 +1,32 @@ + +// Copyright Sergey Krivonos 2017 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + + +#include <boost/mpl/get_tag.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/mpl/aux_/test/assert.hpp> +#include <boost/type_traits/is_same.hpp> + + +struct test_type_get_tag_def +{ + typedef int a_tag; +}; + +BOOST_MPL_GET_TAG_DEF(a_tag); + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same<int, boost::mpl::get_a_tag<test_type_get_tag_def>::type> )); + MPL_ASSERT(( is_same<test_type_get_tag_def::a_tag, boost::mpl::get_a_tag<test_type_get_tag_def>::type> )); +} diff --git a/src/boost/libs/mpl/test/has_xxx.cpp b/src/boost/libs/mpl/test/has_xxx.cpp new file mode 100644 index 00000000..c466db27 --- /dev/null +++ b/src/boost/libs/mpl/test/has_xxx.cpp @@ -0,0 +1,158 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Daniel Walker 2007 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/has_xxx.hpp> +#include <boost/mpl/aux_/config/workaround.hpp> +#include <boost/mpl/aux_/test.hpp> + +BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx) +BOOST_MPL_HAS_XXX_TEMPLATE_NAMED_DEF(has_xxx_template, xxx, false) +BOOST_MPL_HAS_XXX_TEMPLATE_DEF(yyy) + +struct a1 {}; +struct a2 { void xxx(); }; +struct a3 { int xxx; }; +struct a4 { static int xxx(); }; +struct a5 { template< typename T > struct xxx {}; }; + +struct b1 { typedef int xxx; }; +struct b2 { struct xxx; }; +struct b3 { typedef int& xxx; }; +struct b4 { typedef int* xxx; }; +struct b5 { typedef int xxx[10]; }; +struct b6 { typedef void (*xxx)(); }; +struct b7 { typedef void (xxx)(); }; + +struct c1 { template< typename T > struct xxx {}; }; +struct c2 { template< typename T1, typename T2 > struct xxx {}; }; +struct c3 { template< typename T1, typename T2, typename T3 > struct xxx {}; }; +struct c4 { template< typename T1, typename T2, typename T3, typename T4 > struct xxx {}; }; +struct c5 { template< typename T1, typename T2, typename T3, typename T4, typename T5 > struct xxx {}; }; +struct c6 { template< typename T > struct yyy {}; }; +struct c7 { template< typename T1, typename T2 > struct yyy {}; }; + +template< typename T > struct outer; +template< typename T > struct inner { typedef typename T::type type; }; + +// agurt, 15/aug/04: make sure MWCW passes the test in presence of the following +// template +template< typename T > struct xxx; + + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( has_xxx<int> )); + MPL_ASSERT_NOT(( has_xxx_template<int> )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + MPL_ASSERT_NOT(( has_xxx<int&> )); + MPL_ASSERT_NOT(( has_xxx_template<int&> )); + + MPL_ASSERT_NOT(( has_xxx<int*> )); + MPL_ASSERT_NOT(( has_xxx_template<int*> )); + + MPL_ASSERT_NOT(( has_xxx<int[]> )); + MPL_ASSERT_NOT(( has_xxx_template<int[]> )); + + MPL_ASSERT_NOT(( has_xxx<int (*)()> )); + MPL_ASSERT_NOT(( has_xxx_template<int (*)()> )); + + MPL_ASSERT_NOT(( has_xxx<a2> )); + MPL_ASSERT_NOT(( has_xxx_template<a2> )); + + MPL_ASSERT_NOT(( has_xxx<a3> )); + MPL_ASSERT_NOT(( has_xxx_template<a3> )); + + MPL_ASSERT_NOT(( has_xxx<a4> )); + MPL_ASSERT_NOT(( has_xxx_template<a4> )); + +#if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) + MPL_ASSERT_NOT(( has_xxx<a5> )); + MPL_ASSERT(( has_xxx_template<a5> )); +#endif + MPL_ASSERT_NOT(( has_xxx< enum_ > )); + MPL_ASSERT_NOT(( has_xxx_template< enum_ > )); +#endif + + MPL_ASSERT_NOT(( has_xxx<a1> )); + MPL_ASSERT_NOT(( has_xxx_template<a1> )); + + MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > )); + MPL_ASSERT_NOT(( has_xxx_template< outer< inner<int> > > )); + + MPL_ASSERT_NOT(( has_xxx< incomplete > )); + MPL_ASSERT_NOT(( has_xxx_template< incomplete > )); + + MPL_ASSERT_NOT(( has_xxx< abstract > )); + MPL_ASSERT_NOT(( has_xxx_template< abstract > )); + + MPL_ASSERT_NOT(( has_xxx< noncopyable > )); + MPL_ASSERT_NOT(( has_xxx_template< noncopyable > )); + +#if !BOOST_WORKAROUND(__COMO_VERSION__, BOOST_TESTED_AT(4308)) + MPL_ASSERT_NOT(( has_xxx_template<b1> )); + MPL_ASSERT_NOT(( has_xxx_template<b2> )); + MPL_ASSERT_NOT(( has_xxx_template<b3> )); + MPL_ASSERT_NOT(( has_xxx_template<b4> )); + MPL_ASSERT_NOT(( has_xxx_template<b5> )); + MPL_ASSERT_NOT(( has_xxx_template<b6> )); + MPL_ASSERT_NOT(( has_xxx_template<b7> )); +#endif + + // Same name, different args. + MPL_ASSERT(( has_xxx_template<c1> )); + MPL_ASSERT(( has_xxx_template<c2> )); + MPL_ASSERT(( has_xxx_template<c3> )); + MPL_ASSERT(( has_xxx_template<c4> )); + MPL_ASSERT(( has_xxx_template<c5> )); + MPL_ASSERT(( has_yyy<c6> )); + MPL_ASSERT(( has_yyy<c7> )); + + // Different name, different args. + MPL_ASSERT_NOT(( has_xxx_template<c6> )); + MPL_ASSERT_NOT(( has_xxx_template<c7> )); + MPL_ASSERT_NOT(( has_yyy<c1> )); + MPL_ASSERT_NOT(( has_yyy<c2> )); + MPL_ASSERT_NOT(( has_yyy<c3> )); + MPL_ASSERT_NOT(( has_yyy<c4> )); + MPL_ASSERT_NOT(( has_yyy<c5> )); + + MPL_ASSERT(( has_xxx<b1,true_> )); + MPL_ASSERT(( has_xxx<b2,true_> )); + MPL_ASSERT(( has_xxx<b3,true_> )); + MPL_ASSERT(( has_xxx<b4,true_> )); + MPL_ASSERT(( has_xxx<b5,true_> )); + MPL_ASSERT(( has_xxx<b6,true_> )); + MPL_ASSERT(( has_xxx<b7,true_> )); + + MPL_ASSERT(( has_xxx_template<c1,true_> )); + +#if !defined(HAS_XXX_ASSERT) +# define HAS_XXX_ASSERT(x) MPL_ASSERT(x) +#endif + + HAS_XXX_ASSERT(( has_xxx<b1> )); + HAS_XXX_ASSERT(( has_xxx<b2> )); + HAS_XXX_ASSERT(( has_xxx<b3> )); + HAS_XXX_ASSERT(( has_xxx<b4> )); + HAS_XXX_ASSERT(( has_xxx<b5> )); + HAS_XXX_ASSERT(( has_xxx<b6> )); + HAS_XXX_ASSERT(( has_xxx<b7> )); + +#if !defined(HAS_XXX_TEMPLATE_ASSERT) +# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT(x) +#endif + + HAS_XXX_TEMPLATE_ASSERT(( has_xxx_template<c1> )); +} diff --git a/src/boost/libs/mpl/test/identity.cpp b/src/boost/libs/mpl/test/identity.cpp new file mode 100644 index 00000000..db147358 --- /dev/null +++ b/src/boost/libs/mpl/test/identity.cpp @@ -0,0 +1,32 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/apply.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef apply1< identity<>, char >::type t1; + typedef apply1< identity<_1>, int >::type t2; + MPL_ASSERT(( is_same< t1, char > )); + MPL_ASSERT(( is_same< t2, int > )); +} + +MPL_TEST_CASE() +{ + typedef apply1< make_identity<>, char >::type t1; + typedef apply1< make_identity<_1>, int >::type t2; + MPL_ASSERT(( is_same< t1, identity<char> > )); + MPL_ASSERT(( is_same< t2, identity<int> > )); +} diff --git a/src/boost/libs/mpl/test/if.cpp b/src/boost/libs/mpl/test/if.cpp new file mode 100644 index 00000000..df32b6a5 --- /dev/null +++ b/src/boost/libs/mpl/test/if.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/if.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef if_<true_,char,long>::type t1; + typedef if_c<true,char,long>::type t2; + typedef if_<false_,char,long>::type t3; + typedef if_c<false,char,long>::type t4; + + MPL_ASSERT(( is_same<t1, char> )); + MPL_ASSERT(( is_same<t2, char> )); + MPL_ASSERT(( is_same<t3, long> )); + MPL_ASSERT(( is_same<t4, long> )); +} diff --git a/src/boost/libs/mpl/test/index_of.cpp b/src/boost/libs/mpl/test/index_of.cpp new file mode 100644 index 00000000..bffd3218 --- /dev/null +++ b/src/boost/libs/mpl/test/index_of.cpp @@ -0,0 +1,34 @@ + +// Copyright Eric Friedman 2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + + +#include <boost/mpl/index_of.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/void.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list< int, double, float >::type types; + + typedef index_of< types, int >::type index_of_int; + typedef index_of< types, double >::type index_of_double; + typedef index_of< types, float >::type index_of_float; + typedef index_of< types, char >::type index_of_char; + + MPL_ASSERT_RELATION( index_of_int::value, ==, 0 ); + MPL_ASSERT_RELATION( index_of_double::value, ==, 1 ); + MPL_ASSERT_RELATION( index_of_float::value, ==, 2 ); + + MPL_ASSERT(( is_void_< index_of_char > )); +} diff --git a/src/boost/libs/mpl/test/inherit.cpp b/src/boost/libs/mpl/test/inherit.cpp new file mode 100644 index 00000000..4b16adc5 --- /dev/null +++ b/src/boost/libs/mpl/test/inherit.cpp @@ -0,0 +1,40 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/inherit.hpp> +#include <boost/mpl/aux_/test.hpp> + +struct her { typedef her herself; }; +struct my { typedef my myself; }; + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same<inherit<her>::type, her> )); + + typedef inherit<her,my>::type her_my1; + MPL_ASSERT(( is_same<her_my1::herself, her> )); + MPL_ASSERT(( is_same<her_my1::myself, my> )); + + typedef inherit<empty_base,her>::type her1; + MPL_ASSERT(( is_same<her1, her> )); + + typedef inherit<empty_base,her,empty_base,empty_base>::type her2; + MPL_ASSERT(( is_same<her2, her> )); + + typedef inherit<her,empty_base,my>::type her_my2; + MPL_ASSERT(( is_same<her_my2::herself, her> )); + MPL_ASSERT(( is_same<her_my2::myself, my> )); + + typedef inherit<empty_base,empty_base>::type empty; + MPL_ASSERT(( is_same<empty, empty_base> )); +} diff --git a/src/boost/libs/mpl/test/insert.cpp b/src/boost/libs/mpl/test/insert.cpp new file mode 100644 index 00000000..f293cbba --- /dev/null +++ b/src/boost/libs/mpl/test/insert.cpp @@ -0,0 +1,31 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/insert.hpp> + +#include <boost/mpl/find.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef vector_c<int,0,1,3,4,5,6,7,8,9> numbers; + typedef find< numbers,integral_c<int,3> >::type pos; + typedef insert< numbers,pos,integral_c<int,2> >::type range; + + MPL_ASSERT_RELATION( size<range>::value, ==, 10 ); + MPL_ASSERT(( equal< range,range_c<int,0,10> > )); +} diff --git a/src/boost/libs/mpl/test/insert_range.cpp b/src/boost/libs/mpl/test/insert_range.cpp new file mode 100644 index 00000000..865017b7 --- /dev/null +++ b/src/boost/libs/mpl/test/insert_range.cpp @@ -0,0 +1,73 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/insert_range.hpp> +#include <boost/mpl/find.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/set.hpp> +#include <boost/mpl/set_c.hpp> +#include <boost/mpl/map.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/logical.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/joint_view.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef vector_c<int,0,1,7,8,9> numbers; + typedef find< numbers,integral_c<int,7> >::type pos; + typedef insert_range< numbers,pos,range_c<int,2,7> >::type range; + + MPL_ASSERT_RELATION( size<range>::value, ==, 10 ); + MPL_ASSERT(( equal< range,range_c<int,0,10> > )); + + typedef insert_range< list0<>,end< list0<> >::type,list1<int> >::type result2; + MPL_ASSERT_RELATION( size<result2>::value, ==, 1 ); +} + +template<typename A, typename B> +void test_associative() +{ + typedef typename insert_range< A,typename end< A >::type,B >::type C; + + MPL_ASSERT_RELATION( size<C>::value, <=, (size<A>::value + size<B>::value) ); + MPL_ASSERT(( fold< joint_view< A,B >,true_,and_< _1,contains< C,_2 > > > )); +} + +MPL_TEST_CASE() +{ + typedef set3< short,int,long > signed_integers; + typedef set3< unsigned short,unsigned int,unsigned long > unsigned_integers; + test_associative<signed_integers, unsigned_integers>(); + + typedef set_c< int,1,3,5,7,9 > odds; + typedef set_c< int,0,2,4,6,8 > evens; + test_associative<odds, evens>(); + + typedef map2< + pair< void,void* > + , pair< int,int* > + > pointers; + typedef map2< + pair< void const,void const* > + , pair< int const,int const* > + > pointers_to_const; + test_associative<pointers, pointers_to_const>(); +} diff --git a/src/boost/libs/mpl/test/int.cpp b/src/boost/libs/mpl/test/int.cpp new file mode 100644 index 00000000..6c1e24b2 --- /dev/null +++ b/src/boost/libs/mpl/test/int.cpp @@ -0,0 +1,24 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/int.hpp> +#include <boost/preprocessor/repeat.hpp> + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) int_<i> + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int) +} diff --git a/src/boost/libs/mpl/test/integral_c.cpp b/src/boost/libs/mpl/test/integral_c.cpp new file mode 100644 index 00000000..a9f9b0c2 --- /dev/null +++ b/src/boost/libs/mpl/test/integral_c.cpp @@ -0,0 +1,30 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/integral_c.hpp> +#include <boost/preprocessor/repeat.hpp> + +#include "integral_wrapper_test.hpp" + + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) integral_c<T,i> + +#if !(defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)) + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, char) +#endif + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, short) + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, int) + BOOST_PP_REPEAT(10, INTEGRAL_WRAPPER_TEST, long) +} diff --git a/src/boost/libs/mpl/test/integral_wrapper_test.hpp b/src/boost/libs/mpl/test/integral_wrapper_test.hpp new file mode 100644 index 00000000..be31d505 --- /dev/null +++ b/src/boost/libs/mpl/test/integral_wrapper_test.hpp @@ -0,0 +1,63 @@ + +// Copyright Aleksey Gurtovoy 2001-2006 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/next_prior.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/mpl/aux_/config/workaround.hpp> + +#include <cassert> + +#if !BOOST_WORKAROUND(__BORLANDC__, < 0x600) +# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ + BOOST_TEST(( WRAPPER(T,i)() == i )); \ + BOOST_TEST(( WRAPPER(T,i)::value == i )); \ + /**/ +#else +# define INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ + BOOST_TEST(( WRAPPER(T,i)::value == i )); \ + /**/ +#endif + +#if defined(BOOST_NO_CXX11_CONSTEXPR) +#define CONSTEXPR_INTEGRAL_TEST(T, i) +#else +#define CONSTEXPR_INTEGRAL_TEST(T, i) { static_assert(T() == i, "Constexpr for integral constant failed"); } +#endif + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) +// agurt 20/nov/06: see http://article.gmane.org/gmane.comp.lib.boost.devel/151065 +#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \ + { \ + typedef WRAPPER(T,i) borland_tested_type; \ + { typedef is_same< borland_tested_type::value_type, T > borland_test_type; \ + MPL_ASSERT(( borland_test_type )); } \ + { MPL_ASSERT(( is_same< borland_tested_type::type, WRAPPER(T,i) > )); } \ + { MPL_ASSERT(( is_same< next< borland_tested_type >::type, WRAPPER(T,i+1) > )); } \ + { MPL_ASSERT(( is_same< prior< borland_tested_type >::type, WRAPPER(T,i-1) > )); } \ + { MPL_ASSERT_RELATION( (borland_tested_type::value), ==, i ); } \ + CONSTEXPR_INTEGRAL_TEST(borland_tested_type, i) \ + INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ + } \ +/**/ +#else +#define INTEGRAL_WRAPPER_TEST(unused1, i, T) \ + { MPL_ASSERT(( is_same< WRAPPER(T,i)::value_type, T > )); } \ + { MPL_ASSERT(( is_same< WRAPPER(T,i)::type, WRAPPER(T,i) > )); } \ + { MPL_ASSERT(( is_same< next< WRAPPER(T,i) >::type, WRAPPER(T,i+1) > )); } \ + { MPL_ASSERT(( is_same< prior< WRAPPER(T,i) >::type, WRAPPER(T,i-1) > )); } \ + { MPL_ASSERT_RELATION( (WRAPPER(T,i)::value), ==, i ); } \ + CONSTEXPR_INTEGRAL_TEST(WRAPPER(T,i), i) \ + INTEGRAL_WRAPPER_RUNTIME_TEST(i, T) \ +/**/ +#endif + diff --git a/src/boost/libs/mpl/test/is_placeholder.cpp b/src/boost/libs/mpl/test/is_placeholder.cpp new file mode 100644 index 00000000..b90b3a3c --- /dev/null +++ b/src/boost/libs/mpl/test/is_placeholder.cpp @@ -0,0 +1,42 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/is_placeholder.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/preprocessor/repeat.hpp> +#include <boost/preprocessor/inc.hpp> +#include <boost/preprocessor/cat.hpp> + +#define AUX_IS_PLACEHOLDER_TEST(unused1, n, unused2) \ + { MPL_ASSERT(( is_placeholder< \ + BOOST_PP_CAT(_,BOOST_PP_INC(n)) \ + > )); } \ +/**/ + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( is_placeholder<int> )); + MPL_ASSERT_NOT(( is_placeholder<UDT> )); + MPL_ASSERT_NOT(( is_placeholder<incomplete> )); + MPL_ASSERT_NOT(( is_placeholder<abstract> )); + MPL_ASSERT_NOT(( is_placeholder<noncopyable> )); + MPL_ASSERT(( is_placeholder<_> )); + + BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , AUX_IS_PLACEHOLDER_TEST + , unused + ) +} diff --git a/src/boost/libs/mpl/test/is_sequence.cpp b/src/boost/libs/mpl/test/is_sequence.cpp new file mode 100644 index 00000000..1efa8175 --- /dev/null +++ b/src/boost/libs/mpl/test/is_sequence.cpp @@ -0,0 +1,39 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/is_sequence.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename T > struct std_vector +{ + T* begin(); +}; + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( is_sequence< std_vector<int> > )); + MPL_ASSERT_NOT(( is_sequence< int_<0> > )); + MPL_ASSERT_NOT(( is_sequence< int > )); + MPL_ASSERT_NOT(( is_sequence< int& > )); + MPL_ASSERT_NOT(( is_sequence< UDT > )); + MPL_ASSERT_NOT(( is_sequence< UDT* > )); + MPL_ASSERT(( is_sequence< range_c<int,0,0> > )); + MPL_ASSERT(( is_sequence< list<> > )); + MPL_ASSERT(( is_sequence< list<int> > )); + MPL_ASSERT(( is_sequence< vector<> > )); + MPL_ASSERT(( is_sequence< vector<int> > )); +} diff --git a/src/boost/libs/mpl/test/iterator_tags.cpp b/src/boost/libs/mpl/test/iterator_tags.cpp new file mode 100644 index 00000000..6840161c --- /dev/null +++ b/src/boost/libs/mpl/test/iterator_tags.cpp @@ -0,0 +1,23 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/iterator_tags.hpp> + +#include <boost/mpl/less.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + MPL_ASSERT(( less<mpl::forward_iterator_tag,mpl::bidirectional_iterator_tag> )); + MPL_ASSERT(( less<mpl::bidirectional_iterator_tag,mpl::random_access_iterator_tag> )); +} diff --git a/src/boost/libs/mpl/test/joint_view.cpp b/src/boost/libs/mpl/test/joint_view.cpp new file mode 100644 index 00000000..17f824c6 --- /dev/null +++ b/src/boost/libs/mpl/test/joint_view.cpp @@ -0,0 +1,56 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/joint_view.hpp> + +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef joint_view< + range_c<int,0,10> + , range_c<int,10,15> + > numbers; + + typedef range_c<int,0,15> answer; + + MPL_ASSERT(( equal<numbers,answer> )); + MPL_ASSERT(( equal<numbers::type,answer> )); + MPL_ASSERT_RELATION( size<numbers>::value, ==, 15 ); +} + +template< typename View > struct test_is_empty +{ + typedef typename begin<View>::type first_; + typedef typename end<View>::type last_; + + MPL_ASSERT_RELATION( size<View>::value, ==, 0 ); + MPL_ASSERT(( is_same< first_,last_> )); + + MPL_ASSERT_INSTANTIATION( View ); + MPL_ASSERT_INSTANTIATION( first_ ); + MPL_ASSERT_INSTANTIATION( last_ ); +}; + +MPL_TEST_CASE() +{ + test_is_empty< joint_view< list0<>,list0<> > >(); + test_is_empty< joint_view< list<>,list0<> > >(); + test_is_empty< joint_view< list<>,list<> > >(); + test_is_empty< joint_view< list<>, joint_view< list0<>,list0<> > > >(); +} diff --git a/src/boost/libs/mpl/test/lambda.cpp b/src/boost/libs/mpl/test/lambda.cpp new file mode 100644 index 00000000..22e6236c --- /dev/null +++ b/src/boost/libs/mpl/test/lambda.cpp @@ -0,0 +1,78 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/logical.hpp> +#include <boost/mpl/comparison.hpp> +#include <boost/mpl/lambda.hpp> +#include <boost/mpl/size_t.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/sizeof.hpp> +#include <boost/mpl/apply.hpp> + +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_float.hpp> + +struct my +{ + char a[100]; +}; + +MPL_TEST_CASE() +{ + // !(x == char) && !(x == double) || sizeof(x) > 8 + typedef lambda< + or_< + and_< + not_< boost::is_same<_1, char> > + , not_< boost::is_float<_1> > + > + , greater< sizeof_<_1>, mpl::size_t<8> > + > + >::type f; + + MPL_ASSERT_NOT(( apply_wrap1<f,char> )); + MPL_ASSERT_NOT(( apply_wrap1<f,double> )); + MPL_ASSERT(( apply_wrap1<f,long> )); + MPL_ASSERT(( apply_wrap1<f,my> )); +} + +MPL_TEST_CASE() +{ + // x == y || x == my || sizeof(x) == sizeof(y) + typedef lambda< + or_< + boost::is_same<_1, _2> + , boost::is_same<_2, my> + , equal_to< sizeof_<_1>, sizeof_<_2> > + > + >::type f; + + MPL_ASSERT_NOT(( apply_wrap2<f,double,char> )); + MPL_ASSERT_NOT(( apply_wrap2<f,my,int> )); + MPL_ASSERT_NOT(( apply_wrap2<f,my,char[99]> )); + MPL_ASSERT(( apply_wrap2<f,int,int> )); + MPL_ASSERT(( apply_wrap2<f,my,my> )); + MPL_ASSERT(( apply_wrap2<f,signed long, unsigned long> )); +} + +MPL_TEST_CASE() +{ + // bind <-> lambda interaction + typedef lambda< less<_1,_2> >::type pred; + typedef bind2< pred, _1, int_<4> > f; + + MPL_ASSERT(( apply_wrap1< f,int_<3> > )); +} diff --git a/src/boost/libs/mpl/test/lambda_args.cpp b/src/boost/libs/mpl/test/lambda_args.cpp new file mode 100644 index 00000000..fdd26205 --- /dev/null +++ b/src/boost/libs/mpl/test/lambda_args.cpp @@ -0,0 +1,48 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/lambda.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/mpl/aux_/config/gcc.hpp> +#include <boost/mpl/aux_/config/workaround.hpp> + +typedef int UDT::* mem_ptr; +typedef int (UDT::* mem_fun_ptr)(); + +#define AUX_LAMBDA_TEST(T) \ + { MPL_ASSERT(( apply1<lambda< is_same<_,T> >::type, T> )); } \ + { MPL_ASSERT(( apply1<lambda< is_same<T,_> >::type, T> )); } \ + { MPL_ASSERT(( apply2<lambda< is_same<_,_> >::type, T, T> )); } \ +/**/ + +MPL_TEST_CASE() +{ + AUX_LAMBDA_TEST( UDT ); + AUX_LAMBDA_TEST( abstract ); + AUX_LAMBDA_TEST( noncopyable ); + AUX_LAMBDA_TEST( incomplete ); + AUX_LAMBDA_TEST( int ); + AUX_LAMBDA_TEST( void ); + AUX_LAMBDA_TEST( double ); + AUX_LAMBDA_TEST( int& ); + AUX_LAMBDA_TEST( int* ); +#if !BOOST_WORKAROUND(BOOST_MPL_CFG_GCC, <= 0x0295) \ + && !BOOST_WORKAROUND(__BORLANDC__, < 0x600) + AUX_LAMBDA_TEST( int[] ); +#endif + AUX_LAMBDA_TEST( int[10] ); + AUX_LAMBDA_TEST( int (*)() ) + AUX_LAMBDA_TEST( mem_ptr ); + AUX_LAMBDA_TEST( mem_fun_ptr ); +} diff --git a/src/boost/libs/mpl/test/list.cpp b/src/boost/libs/mpl/test/list.cpp new file mode 100644 index 00000000..655905a1 --- /dev/null +++ b/src/boost/libs/mpl/test/list.cpp @@ -0,0 +1,68 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/list.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/empty.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef list0<> l0; + typedef list1<char> l1; + typedef list2<char,long> l2; + typedef list9<char,char,char,char,char,char,char,char,char> l9; + + MPL_ASSERT_RELATION(size<l0>::value, ==, 0); + MPL_ASSERT_RELATION(size<l1>::value, ==, 1); + MPL_ASSERT_RELATION(size<l2>::value, ==, 2); + MPL_ASSERT_RELATION(size<l9>::value, ==, 9); + + MPL_ASSERT(( empty<l0> )); + MPL_ASSERT_NOT(( empty<l1> )); + MPL_ASSERT_NOT(( empty<l2> )); + MPL_ASSERT_NOT(( empty<l9> )); + + MPL_ASSERT(( is_same<front<l1>::type,char> )); + MPL_ASSERT(( is_same<front<l2>::type,char> )); + MPL_ASSERT(( is_same<front<l9>::type,char> )); +} + +MPL_TEST_CASE() +{ + typedef list2<char,long> l2; + + typedef begin<l2>::type i1; + typedef next<i1>::type i2; + typedef next<i2>::type i3; + + MPL_ASSERT(( is_same<deref<i1>::type,char> )); + MPL_ASSERT(( is_same<deref<i2>::type,long> )); + MPL_ASSERT(( is_same< i3, end<l2>::type > )); +} + +MPL_TEST_CASE() +{ + typedef list0<> l0; + + typedef push_front<l0,char>::type l1; + MPL_ASSERT(( is_same<front<l1>::type,char> )); + + typedef push_front<l1,long>::type l2; + MPL_ASSERT(( is_same<front<l2>::type,long> )); +} diff --git a/src/boost/libs/mpl/test/list_c.cpp b/src/boost/libs/mpl/test/list_c.cpp new file mode 100644 index 00000000..7683fda0 --- /dev/null +++ b/src/boost/libs/mpl/test/list_c.cpp @@ -0,0 +1,81 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/size.hpp> +#include <boost/static_assert.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +#if !BOOST_WORKAROUND(BOOST_MSVC,<= 1200) +MPL_TEST_CASE() +{ + typedef list_c<bool,true>::type l1; + typedef list_c<bool,false>::type l2; + + MPL_ASSERT(( is_same< l1::value_type, bool > )); + MPL_ASSERT(( is_same< l2::value_type, bool > )); + + MPL_ASSERT_RELATION( front<l1>::type::value, ==, true ); + MPL_ASSERT_RELATION( front<l2>::type::value, ==, false ); +} +#endif + +MPL_TEST_CASE() +{ + typedef list_c<int,-1>::type l1; + typedef list_c<int,0,1>::type l2; + typedef list_c<int,1,2,3>::type l3; + + MPL_ASSERT(( is_same< l1::value_type, int > )); + MPL_ASSERT(( is_same< l2::value_type, int > )); + MPL_ASSERT(( is_same< l3::value_type, int > )); + + MPL_ASSERT_RELATION( size<l1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<l2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<l3>::value, ==, 3 ); + MPL_ASSERT_RELATION( front<l1>::type::value, ==, -1 ); + MPL_ASSERT_RELATION( front<l2>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front<l3>::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef list_c<unsigned,0>::type l1; + typedef list_c<unsigned,1,2>::type l2; + + MPL_ASSERT(( is_same< l1::value_type, unsigned > )); + MPL_ASSERT(( is_same< l2::value_type, unsigned > )); + + MPL_ASSERT_RELATION( size<l1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<l2>::value, ==, 2 ); + MPL_ASSERT_RELATION( front<l1>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front<l2>::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef list_c<unsigned,2,1> l2; + + MPL_ASSERT(( is_same< l2::value_type, unsigned > )); + + typedef begin<l2>::type i1; + typedef next<i1>::type i2; + typedef next<i2>::type i3; + + MPL_ASSERT_RELATION( deref<i1>::type::value, ==, 2 ); + MPL_ASSERT_RELATION( deref<i2>::type::value, ==, 1 ); + MPL_ASSERT(( is_same< i3, end<l2>::type > )); +} diff --git a/src/boost/libs/mpl/test/logical.cpp b/src/boost/libs/mpl/test/logical.cpp new file mode 100644 index 00000000..bea6b7ac --- /dev/null +++ b/src/boost/libs/mpl/test/logical.cpp @@ -0,0 +1,41 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/logical.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/aux_/test.hpp> + +struct unknown; + +using mpl::true_; +using mpl::false_; + +MPL_TEST_CASE() +{ + MPL_ASSERT(( mpl::and_< true_,true_ > )); + MPL_ASSERT_NOT(( mpl::and_< false_,true_ > )); + MPL_ASSERT_NOT(( mpl::and_< true_,false_ > )); + MPL_ASSERT_NOT(( mpl::and_< false_,false_ > )); + MPL_ASSERT_NOT(( mpl::and_< false_,unknown > )); + MPL_ASSERT_NOT(( mpl::and_< false_,unknown,unknown > )); + + MPL_ASSERT(( mpl::or_< true_,true_ > )); + MPL_ASSERT(( mpl::or_< false_,true_ > )); + MPL_ASSERT(( mpl::or_< true_,false_ > )); + MPL_ASSERT_NOT(( mpl::or_< false_,false_ > )); + MPL_ASSERT(( mpl::or_< true_,unknown > )); + MPL_ASSERT(( mpl::or_< true_,unknown,unknown > )); + + MPL_ASSERT_NOT(( mpl::not_< true_ > )); + MPL_ASSERT(( mpl::not_< false_ > )); +} diff --git a/src/boost/libs/mpl/test/lower_bound.cpp b/src/boost/libs/mpl/test/lower_bound.cpp new file mode 100644 index 00000000..95be40de --- /dev/null +++ b/src/boost/libs/mpl/test/lower_bound.cpp @@ -0,0 +1,28 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/lower_bound.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list_c<int,1,2,3,3,3,5,8> numbers; + typedef lower_bound< numbers, int_<4> >::type iter; + + MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 ); + MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/map.cpp b/src/boost/libs/mpl/test/map.cpp new file mode 100644 index 00000000..f39b85d8 --- /dev/null +++ b/src/boost/libs/mpl/test/map.cpp @@ -0,0 +1,235 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/map.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/erase_key.hpp> +#include <boost/mpl/erase_key.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/clear.hpp> +#include <boost/mpl/has_key.hpp> +#include <boost/mpl/order.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/empty.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef map2< + mpl::pair<int,unsigned> + , mpl::pair<char,unsigned char> + > m_; + + typedef erase_key<m_,char>::type m; + + MPL_ASSERT_RELATION( size<m>::type::value, ==, 1 ); + MPL_ASSERT_NOT(( empty<m> )); + MPL_ASSERT(( is_same< clear<m>::type,map0<> > )); + + MPL_ASSERT(( is_same< at<m,int>::type,unsigned > )); + MPL_ASSERT(( is_same< at<m,char>::type,void_ > )); + MPL_ASSERT(( contains< m,mpl::pair<int,unsigned> > )); + MPL_ASSERT_NOT(( contains< m,mpl::pair<int,int> > )); + MPL_ASSERT_NOT(( contains< m,mpl::pair<char,unsigned char> > )); + + MPL_ASSERT_NOT(( has_key<m,char>::type )); + MPL_ASSERT(( has_key<m,int>::type )); + + MPL_ASSERT_NOT(( is_same< order<m,int>::type, void_ > )); + MPL_ASSERT(( is_same< order<m,char>::type,void_ > )); + + typedef begin<m>::type first; + typedef end<m>::type last; + + MPL_ASSERT(( is_same< deref<first>::type,mpl::pair<int,unsigned> > )); + MPL_ASSERT(( is_same< next<first>::type,last > )); + + typedef insert<m,mpl::pair<char,long> >::type m2; + + MPL_ASSERT_RELATION( size<m2>::type::value, ==, 2 ); + MPL_ASSERT_NOT(( empty<m2>::type )); + MPL_ASSERT(( is_same< clear<m2>::type,map0<> > )); + MPL_ASSERT(( is_same< at<m2,int>::type,unsigned > )); + MPL_ASSERT(( is_same< at<m2,char>::type,long > )); + + MPL_ASSERT(( contains< m2,mpl::pair<int,unsigned> > )); + MPL_ASSERT_NOT(( contains< m2,mpl::pair<int,int> > )); + MPL_ASSERT_NOT(( contains< m2,mpl::pair<char,unsigned char> > )); + MPL_ASSERT(( contains< m2,mpl::pair<char,long> > )); + + MPL_ASSERT(( has_key<m2,char>::type )); + MPL_ASSERT_NOT(( has_key<m2,long>::type )); + MPL_ASSERT_NOT(( is_same< order<m2,int>::type, void_ > )); + MPL_ASSERT_NOT(( is_same< order<m2,char>::type, void_ > )); + MPL_ASSERT_NOT(( is_same< order<m2,char>::type, order<m2,int>::type > )); + + typedef begin<m2>::type first2; + typedef end<m2>::type last2; + + MPL_ASSERT(( is_same<deref<first2>::type,mpl::pair<int,unsigned> > )); + typedef next<first2>::type iter; + MPL_ASSERT(( is_same<deref<iter>::type,mpl::pair<char,long> > )); + MPL_ASSERT(( is_same< next<iter>::type,last2 > )); + + typedef insert<m2,mpl::pair<int,unsigned> >::type s2_1; + MPL_ASSERT(( is_same<m2,s2_1> )); + + typedef insert<m2,mpl::pair<long,unsigned> >::type m3; + MPL_ASSERT_RELATION( size<m3>::type::value, ==, 3 ); + MPL_ASSERT(( has_key<m3,long>::type )); + MPL_ASSERT(( has_key<m3,int>::type )); + MPL_ASSERT(( has_key<m3,char>::type )); + MPL_ASSERT(( contains< m3,mpl::pair<long,unsigned> > )); + MPL_ASSERT(( contains< m3,mpl::pair<int,unsigned> > )); + + typedef insert<m,mpl::pair<char,long> >::type m1; + MPL_ASSERT_RELATION( size<m1>::type::value, ==, 2 ); + MPL_ASSERT(( is_same< at<m1,int>::type,unsigned > )); + MPL_ASSERT(( is_same< at<m1,char>::type,long > )); + + MPL_ASSERT(( contains< m1,mpl::pair<int,unsigned> > )); + MPL_ASSERT_NOT(( contains< m1,mpl::pair<int,int> > )); + MPL_ASSERT_NOT(( contains< m1,mpl::pair<char,unsigned char> > )); + MPL_ASSERT(( contains< m1,mpl::pair<char,long> > )); + + MPL_ASSERT(( is_same< m1,m2 > )); + + typedef erase_key<m1,char>::type m_1; + MPL_ASSERT(( is_same<m,m_1> )); + MPL_ASSERT_RELATION( size<m_1>::type::value, ==, 1 ); + MPL_ASSERT(( is_same< at<m_1,char>::type,void_ > )); + MPL_ASSERT(( is_same< at<m_1,int>::type,unsigned > )); + + typedef erase_key<m3,char>::type m2_1; + MPL_ASSERT_RELATION( size<m2_1>::type::value, ==, 2 ); + MPL_ASSERT(( is_same< at<m2_1,char>::type,void_ > )); + MPL_ASSERT(( is_same< at<m2_1,int>::type,unsigned > )); + MPL_ASSERT(( is_same< at<m2_1,long>::type,unsigned > )); +} + +MPL_TEST_CASE() +{ + typedef map0<> m; + + MPL_ASSERT_RELATION( size<m>::type::value, ==, 0 ); + MPL_ASSERT(( empty<m>::type )); + + MPL_ASSERT(( is_same< clear<m>::type,map0<> > )); + MPL_ASSERT(( is_same< at<m,char>::type,void_ > )); + + MPL_ASSERT_NOT(( has_key<m,char>::type )); + MPL_ASSERT_NOT(( has_key<m,int>::type )); + MPL_ASSERT_NOT(( has_key<m,UDT>::type )); + MPL_ASSERT_NOT(( has_key<m,incomplete>::type )); + + MPL_ASSERT_NOT(( has_key<m,char const>::type )); + MPL_ASSERT_NOT(( has_key<m,int const>::type )); + MPL_ASSERT_NOT(( has_key<m,UDT const>::type )); + MPL_ASSERT_NOT(( has_key<m,incomplete const>::type )); + + MPL_ASSERT_NOT(( has_key<m,int*>::type )); + MPL_ASSERT_NOT(( has_key<m,UDT*>::type )); + MPL_ASSERT_NOT(( has_key<m,incomplete*>::type )); + + MPL_ASSERT_NOT(( has_key<m,int&>::type )); + MPL_ASSERT_NOT(( has_key<m,UDT&>::type )); + MPL_ASSERT_NOT(( has_key<m,incomplete&>::type )); + + typedef insert<m,mpl::pair<char,int> >::type m1; + MPL_ASSERT_RELATION( size<m1>::type::value, ==, 1 ); + MPL_ASSERT(( is_same< at<m1,char>::type,int > )); + + typedef erase_key<m,char>::type m0_1; + MPL_ASSERT_RELATION( size<m0_1>::type::value, ==, 0 ); + MPL_ASSERT(( is_same< at<m0_1,char>::type,void_ > )); +} + +// Use a template for testing so that GCC will show us the actual types involved +template <class M> +void test() +{ + MPL_ASSERT_RELATION( size<M>::value, ==, 3 ); + + typedef typename end<M>::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<int,int*> >::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<long,long*> >::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<M,mpl::pair<char,char*> >::type,not_found> )); + BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<M,int>::type,not_found> )); +}; + +MPL_TEST_CASE() +{ + typedef map< mpl::pair<int,int*> > map_of_1_pair; + typedef begin<map_of_1_pair>::type iter_to_1_pair; + + BOOST_MPL_ASSERT(( + is_same< + deref<iter_to_1_pair>::type + , mpl::pair<int,int*> + > + )); + + typedef map< + mpl::pair<int,int*> + , mpl::pair<long,long*> + , mpl::pair<char,char*> + > mymap; + + test<mymap>(); + test<mymap::type>(); +} + +MPL_TEST_CASE() +{ + typedef mpl::erase_key< + mpl::map< + mpl::pair<char, double> + , mpl::pair<int, float> + > + , char + >::type int_to_float_map; + + typedef mpl::insert< + int_to_float_map + , mpl::pair<char, long> + >::type with_char_too; + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::at<with_char_too, char>::type + , long + > + )); +} + +MPL_TEST_CASE() +{ + typedef insert< map<>, pair<int,int> >::type little_map; + + MPL_ASSERT_RELATION(size<little_map>::value, ==, 1); + MPL_ASSERT_RELATION(size<little_map::type>::value, ==, 1); +} + +MPL_TEST_CASE() +{ + typedef erase_key< map< pair<float,float>, pair<int,int> >, float >::type little_map; + + MPL_ASSERT_RELATION(size<little_map>::value, ==, 1); + MPL_ASSERT_RELATION(size<little_map::type>::value, ==, 1); +} diff --git a/src/boost/libs/mpl/test/max_element.cpp b/src/boost/libs/mpl/test/max_element.cpp new file mode 100644 index 00000000..65bb0f3a --- /dev/null +++ b/src/boost/libs/mpl/test/max_element.cpp @@ -0,0 +1,26 @@ + +// Copyright Eric Friedman 2002-2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/max_element.hpp> + +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list_c<int,3,4,2,0,-5,8,-1,7>::type numbers; + typedef max_element< numbers >::type iter; + typedef deref<iter>::type max_value; + + MPL_ASSERT_RELATION( max_value::value, ==, 8 ); +} diff --git a/src/boost/libs/mpl/test/min_max.cpp b/src/boost/libs/mpl/test/min_max.cpp new file mode 100644 index 00000000..02ead233 --- /dev/null +++ b/src/boost/libs/mpl/test/min_max.cpp @@ -0,0 +1,27 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/min_max.hpp> +#include <boost/mpl/int.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + MPL_ASSERT(( is_same< mpl::min< int_<5>,int_<7> >::type,int_<5> > )); + MPL_ASSERT(( is_same< mpl::max< int_<5>,int_<7> >::type,int_<7> > )); + + MPL_ASSERT(( is_same< mpl::min< int_<-5>,int_<-7> >::type,int_<-7> > )); + MPL_ASSERT(( is_same< mpl::max< int_<-5>,int_<-7> >::type,int_<-5> > )); +} diff --git a/src/boost/libs/mpl/test/multiset.cpp b/src/boost/libs/mpl/test/multiset.cpp new file mode 100644 index 00000000..48a6176e --- /dev/null +++ b/src/boost/libs/mpl/test/multiset.cpp @@ -0,0 +1,107 @@ + +// Copyright Aleksey Gurtovoy 2003-2006 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/multiset/multiset0.hpp> +//#include <boost/mpl/multiset/multiset10.hpp> + +#include <boost/mpl/insert.hpp> +#include <boost/mpl/count.hpp> +#include <boost/mpl/aux_/test.hpp> + +#include <boost/mpl/assert.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/find.hpp> + +#include <boost/config.hpp> + +/* +struct test_data1 +{ + typedef multiset0<> s0; + typedef multiset1<int> s1; + typedef multiset2<int,char&> s2; + typedef multiset3<int,char&,int> s3; + typedef multiset4<int,char&,int,abstract> s4; +}; + +struct test_data2 +{ + typedef multiset<> s0; + typedef multiset<int> s1; + typedef multiset<int,char&> s2; + typedef multiset<int,char&,int> s3; + typedef multiset<int,char&,int,abstract> s4; +}; +*/ + +template< typename S0 > +struct test_data +{ + typedef S0 s0; + typedef typename insert<s0,int>::type s1; + typedef typename insert<s1,char&>::type s2; + typedef typename insert<s2,int>::type s3; + typedef typename insert<s3,abstract>::type s4; +}; + + +template< typename T > +void count_test() +{ + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s0,int>::value ), ==, 0 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s1,int>::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,int>::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s2,char&>::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,int>::value ), ==, 2 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s3,char&>::value ), ==, 1 ); + MPL_ASSERT_RELATION( ( count<BOOST_DEDUCED_TYPENAME T::s4,abstract>::value ), ==, 1 ); +} + +MPL_TEST_CASE() +{ + //count_test<test_data1>(); + //count_test<test_data2>(); + //count_test< test_data< multiset<> > >(); + count_test< test_data< multiset0<> > >(); +} + +/* +// Use a template for testing so that GCC will show us the actual types involved +template <class S> +void find_test() +{ + BOOST_MPL_ASSERT_RELATION( size<S>::value, ==, 3 ); + + typedef typename end<S>::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,int>::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,long>::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char>::type,not_found> )); + BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char*>::type,not_found> )); +} +*/ + +MPL_TEST_CASE() +{ + // agurt 11/jun/06: multiset does not implement iterators yet! + // typedef insert<multiset0<>, int>::type set_of_1_int; + // typedef begin<set_of_1_int>::type iter_to_1_int; + // BOOST_MPL_ASSERT(( is_same< deref<iter_to_1_int>::type, int > )); + + typedef multiset0<> s0; + typedef insert<s0,int>::type s1; + typedef insert<s1,long>::type s2; + typedef insert<s2,char>::type myset; + + // find_test<myset>(); + // find_test<myset::type>(); +} diff --git a/src/boost/libs/mpl/test/next.cpp b/src/boost/libs/mpl/test/next.cpp new file mode 100644 index 00000000..d7356c72 --- /dev/null +++ b/src/boost/libs/mpl/test/next.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/next.hpp> +#include <boost/mpl/prior.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef int_<0> _0; + typedef int_<1> _1; + typedef int_<2> _2; + + MPL_ASSERT(( is_same< next<_0>::type, _1 > )); + MPL_ASSERT(( is_same< next<_1>::type, _2 > )); + MPL_ASSERT(( is_same< prior<_1>::type, _0 > )); + MPL_ASSERT(( is_same< prior<_2>::type, _1 > )); +} diff --git a/src/boost/libs/mpl/test/no_has_xxx.cpp b/src/boost/libs/mpl/test/no_has_xxx.cpp new file mode 100644 index 00000000..53e4691f --- /dev/null +++ b/src/boost/libs/mpl/test/no_has_xxx.cpp @@ -0,0 +1,30 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + + +// This file tests that we have the right value for +// BOOST_MPL_CFG_NO_HAS_XXX, and that 'has_xxx' doesn't just fail to +// compile arbitrarily. + +#include <boost/mpl/aux_/config/has_xxx.hpp> + +#if defined(BOOST_MPL_CFG_NO_HAS_XXX) +# define HAS_XXX_ASSERT(x) MPL_ASSERT_NOT(x) +#endif + +#if defined(BOOST_MPL_CFG_NO_HAS_XXX_TEMPLATE) +# define HAS_XXX_TEMPLATE_ASSERT(x) MPL_ASSERT_NOT(x) +#endif + +#include "has_xxx.cpp" diff --git a/src/boost/libs/mpl/test/numeric_ops.cpp b/src/boost/libs/mpl/test/numeric_ops.cpp new file mode 100644 index 00000000..453b4aab --- /dev/null +++ b/src/boost/libs/mpl/test/numeric_ops.cpp @@ -0,0 +1,155 @@ + +// Copyright Aleksey Gurtovoy 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/arithmetic.hpp> +#include <boost/mpl/comparison.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/long.hpp> +#include <boost/mpl/aux_/test.hpp> + +struct complex_tag : int_<10> {}; + +template< typename Re, typename Im > struct complex +{ + typedef complex_tag tag; + typedef complex type; + typedef Re real; + typedef Im imag; +}; + +template< typename C > struct real : C::real {}; +template< typename C > struct imag : C::imag {}; + +namespace boost { namespace mpl { + +template<> struct BOOST_MPL_AUX_NUMERIC_CAST< integral_c_tag,complex_tag > +{ + template< typename N > struct apply + : complex< N, integral_c< typename N::value_type, 0 > > + { + }; +}; + +template<> +struct plus_impl< complex_tag,complex_tag > +{ + template< typename N1, typename N2 > struct apply + : complex< + plus< typename N1::real, typename N2::real > + , plus< typename N1::imag, typename N2::imag > + > + { + }; +}; + +template<> +struct times_impl< complex_tag,complex_tag > +{ + template< typename N1, typename N2 > struct apply + : complex< + minus< + times< typename N1::real, typename N2::real > + , times< typename N1::imag, typename N2::imag > + > + , plus< + times< typename N1::real, typename N2::imag > + , times< typename N1::imag, typename N2::real > + > + > + { + }; +}; + +template<> +struct equal_to_impl< complex_tag,complex_tag > +{ + template< typename N1, typename N2 > struct apply + : and_< + equal_to< typename N1::real, typename N2::real > + , equal_to< typename N1::imag, typename N2::imag > + > + { + }; +}; + +}} + + +typedef int_<2> i; +typedef complex< int_<5>, int_<-1> > c1; +typedef complex< int_<-5>, int_<1> > c2; + +MPL_TEST_CASE() +{ + typedef plus<c1,c2>::type r1; + MPL_ASSERT_RELATION( real<r1>::value, ==, 0 ); + MPL_ASSERT_RELATION( imag<r1>::value, ==, 0 ); + + typedef plus<c1,c1>::type r2; + MPL_ASSERT_RELATION( real<r2>::value, ==, 10 ); + MPL_ASSERT_RELATION( imag<r2>::value, ==, -2 ); + + typedef plus<c2,c2>::type r3; + MPL_ASSERT_RELATION( real<r3>::value, ==, -10 ); + MPL_ASSERT_RELATION( imag<r3>::value, ==, 2 ); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + typedef plus<c1,i>::type r4; + MPL_ASSERT_RELATION( real<r4>::value, ==, 7 ); + MPL_ASSERT_RELATION( imag<r4>::value, ==, -1 ); + + typedef plus<i,c2>::type r5; + MPL_ASSERT_RELATION( real<r5>::value, ==, -3 ); + MPL_ASSERT_RELATION( imag<r5>::value, ==, 1 ); +#endif +} + +MPL_TEST_CASE() +{ + typedef times<c1,c2>::type r1; + MPL_ASSERT_RELATION( real<r1>::value, ==, -24 ); + MPL_ASSERT_RELATION( imag<r1>::value, ==, 10 ); + + typedef times<c1,c1>::type r2; + MPL_ASSERT_RELATION( real<r2>::value, ==, 24 ); + MPL_ASSERT_RELATION( imag<r2>::value, ==, -10 ); + + typedef times<c2,c2>::type r3; + MPL_ASSERT_RELATION( real<r3>::value, ==, 24 ); + MPL_ASSERT_RELATION( imag<r3>::value, ==, -10 ); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + typedef times<c1,i>::type r4; + MPL_ASSERT_RELATION( real<r4>::value, ==, 10 ); + MPL_ASSERT_RELATION( imag<r4>::value, ==, -2 ); + + typedef times<i,c2>::type r5; + MPL_ASSERT_RELATION( real<r5>::value, ==, -10 ); + MPL_ASSERT_RELATION( imag<r5>::value, ==, 2 ); +#endif +} + +MPL_TEST_CASE() +{ + MPL_ASSERT(( equal_to<c1,c1> )); + MPL_ASSERT(( equal_to<c2,c2> )); + MPL_ASSERT_NOT(( equal_to<c1,c2> )); + + MPL_ASSERT(( equal_to<c1, complex< long_<5>, long_<-1> > > )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + MPL_ASSERT_NOT(( equal_to<c1,i> )); + MPL_ASSERT_NOT(( equal_to<i,c2> )); +#endif +} diff --git a/src/boost/libs/mpl/test/pair_view.cpp b/src/boost/libs/mpl/test/pair_view.cpp new file mode 100644 index 00000000..937ff427 --- /dev/null +++ b/src/boost/libs/mpl/test/pair_view.cpp @@ -0,0 +1,45 @@ + +// Copyright David Abrahams 2003-2004 +// Copyright Aleksey Gurtovoy 2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/pair_view.hpp> +#include <boost/mpl/vector/vector50_c.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef range_c<int,0,10> r; + typedef vector10_c<int,9,8,7,6,5,4,3,2,1,10> v; + + typedef pair_view<r,v> view; + typedef begin<view>::type first_; + typedef end<view>::type last_; + + MPL_ASSERT(( is_same< first_::category, mpl::random_access_iterator_tag > )); + + MPL_ASSERT(( is_same< advance_c<first_,0>::type, first_ > )); + MPL_ASSERT(( is_same< advance_c<last_,0>::type, last_ > )); + MPL_ASSERT(( is_same< advance_c<first_,10>::type, last_ > )); + MPL_ASSERT(( is_same< advance_c<last_,-10>::type, first_ > )); + + typedef advance_c<first_,5>::type iter; + + MPL_ASSERT(( is_same< + deref<iter>::type + , mpl::pair< integral_c<int,5>,integral_c<int,4> > + > )); + +} diff --git a/src/boost/libs/mpl/test/partition.cpp b/src/boost/libs/mpl/test/partition.cpp new file mode 100644 index 00000000..947c310d --- /dev/null +++ b/src/boost/libs/mpl/test/partition.cpp @@ -0,0 +1,42 @@ + +// Copyright Aleksey Gurtovoy 2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/partition.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/back_inserter.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/modulus.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename N > struct is_odd + : modulus< N, int_<2> > +{ + BOOST_MPL_AUX_LAMBDA_SUPPORT(1, is_odd, (N)) +}; + + +MPL_TEST_CASE() +{ + typedef partition< + range_c<int,0,10> + , is_odd<_1> + , mpl::back_inserter< vector<> > + , mpl::back_inserter< vector<> > + >::type r; + + MPL_ASSERT(( equal< r::first, vector_c<int,1,3,5,7,9> > )); + MPL_ASSERT(( equal< r::second, vector_c<int,0,2,4,6,8> > )); +} diff --git a/src/boost/libs/mpl/test/pop_front.cpp b/src/boost/libs/mpl/test/pop_front.cpp new file mode 100644 index 00000000..71512c10 --- /dev/null +++ b/src/boost/libs/mpl/test/pop_front.cpp @@ -0,0 +1,36 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<long>::type types1; + typedef list<int,long>::type types2; + typedef list<char,int,long>::type types3; + + typedef pop_front<types1>::type result1; + typedef pop_front<types2>::type result2; + typedef pop_front<types3>::type result3; + + MPL_ASSERT_RELATION( size<result1>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<result2>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<result3>::value, ==, 2 ); + + MPL_ASSERT(( is_same< front<result2>::type, long > )); + MPL_ASSERT(( is_same< front<result3>::type, int > )); +} diff --git a/src/boost/libs/mpl/test/print.cpp b/src/boost/libs/mpl/test/print.cpp new file mode 100644 index 00000000..12295df3 --- /dev/null +++ b/src/boost/libs/mpl/test/print.cpp @@ -0,0 +1,22 @@ + +// Copyright Aleksey Gurtovoy 2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/print.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef print<int>::type t; +} diff --git a/src/boost/libs/mpl/test/push_back.cpp b/src/boost/libs/mpl/test/push_back.cpp new file mode 100644 index 00000000..bdf7a920 --- /dev/null +++ b/src/boost/libs/mpl/test/push_back.cpp @@ -0,0 +1,52 @@ + +// Copyright Steven Watanabe 2009 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date: 2008-10-10 02:21:07 -0700 (Fri, 10 Oct 2008) $ +// $Revision: 49240 $ + +#include <boost/mpl/push_back.hpp> + +#include <boost/mpl/aux_/test.hpp> + +struct no_push_back_tag {}; + +struct no_push_back +{ + typedef no_push_back_tag tag; +}; + +struct has_push_back_tag {}; + +struct with_push_back +{ + typedef has_push_back_tag tag; +}; + +namespace boost { namespace mpl { + +template<> +struct push_back_impl< has_push_back_tag > +{ + template<class Seq, class T> struct apply + { + typedef no_push_back type; + }; +}; + +}} + +MPL_TEST_CASE() +{ + MPL_ASSERT_NOT(( has_push_back< no_push_back > )); + MPL_ASSERT(( has_push_back< with_push_back > )); + + typedef push_back< with_push_back , int >::type test; + MPL_ASSERT(( is_same< test, no_push_back > )); +} diff --git a/src/boost/libs/mpl/test/push_front.cpp b/src/boost/libs/mpl/test/push_front.cpp new file mode 100644 index 00000000..f5edc2f9 --- /dev/null +++ b/src/boost/libs/mpl/test/push_front.cpp @@ -0,0 +1,50 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright Steven Watanabe 2009 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/list/list10.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/front.hpp> + +#include <boost/mpl/aux_/test.hpp> + +struct no_push_front_tag {}; + +struct no_push_front +{ + typedef no_push_front_tag tag; +}; + +MPL_TEST_CASE() +{ + typedef push_front<list0<>,long>::type res1; + typedef push_front<list1<long>,int>::type res2; + typedef push_front<list2<int,long>,char>::type res3; + + MPL_ASSERT_RELATION( size<res1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<res2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<res3>::value, ==, 3 ); + + MPL_ASSERT(( is_same< front<res1>::type, long > )); + MPL_ASSERT(( is_same< front<res2>::type, int > )); + MPL_ASSERT(( is_same< front<res3>::type, char > )); + + MPL_ASSERT(( has_push_front< list0<> > )); + MPL_ASSERT(( has_push_front< list1<long> > )); + + MPL_ASSERT_NOT(( has_push_back< list0<> > )); + + MPL_ASSERT_NOT(( has_push_front< no_push_front > )); +} diff --git a/src/boost/libs/mpl/test/quote.cpp b/src/boost/libs/mpl/test/quote.cpp new file mode 100644 index 00000000..45e97f8d --- /dev/null +++ b/src/boost/libs/mpl/test/quote.cpp @@ -0,0 +1,42 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/quote.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/mpl/aux_/test.hpp> + +template< typename T > struct f1 +{ + typedef T type; +}; + +template< + typename T1, typename T2, typename T3, typename T4, typename T5 + > +struct f5 +{ +#if !defined(BOOST_MPL_CFG_NO_IMPLICIT_METAFUNCTIONS) + // no 'type' member! +#else + typedef f5 type; +#endif +}; + +MPL_TEST_CASE() +{ + typedef quote1<f1>::apply<int>::type t1; + typedef quote5<f5>::apply<char,short,int,long,float>::type t5; + + MPL_ASSERT(( boost::is_same< t1, int > )); + MPL_ASSERT(( boost::is_same< t5, f5<char,short,int,long,float> > )); +} diff --git a/src/boost/libs/mpl/test/range_c.cpp b/src/boost/libs/mpl/test/range_c.cpp new file mode 100644 index 00000000..90c32cc4 --- /dev/null +++ b/src/boost/libs/mpl/test/range_c.cpp @@ -0,0 +1,60 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/advance.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/empty.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/back.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef range_c<int,0,0> range0; + typedef range_c<int,0,1> range1; + typedef range_c<int,0,10> range10; + + MPL_ASSERT_RELATION( size<range0>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<range1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<range10>::value, ==, 10 ); + + MPL_ASSERT(( empty<range0> )); + MPL_ASSERT_NOT(( empty<range1> )); + MPL_ASSERT_NOT(( empty<range10> )); + + MPL_ASSERT(( is_same< begin<range0>::type, end<range0>::type > )); + MPL_ASSERT_NOT(( is_same<begin<range1>::type, end<range1>::type > )); + MPL_ASSERT_NOT(( is_same<begin<range10>::type, end<range10>::type > )); + + MPL_ASSERT_RELATION( front<range1>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( back<range1>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front<range10>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( back<range10>::type::value, ==, 9 ); +} + +MPL_TEST_CASE() +{ + typedef range_c<unsigned char,0,10> r; + typedef begin<r>::type first; + typedef end<r>::type last; + + MPL_ASSERT(( is_same< advance_c<first,10>::type, last > )); + MPL_ASSERT(( is_same< advance_c<last,-10>::type, first > )); + + MPL_ASSERT_RELATION( ( mpl::distance<first,last>::value ), ==, 10 ); + + typedef advance_c<first,5>::type iter; + MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/remove.cpp b/src/boost/libs/mpl/test/remove.cpp new file mode 100644 index 00000000..6147b08d --- /dev/null +++ b/src/boost/libs/mpl/test/remove.cpp @@ -0,0 +1,28 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/remove.hpp> +#include <boost/mpl/vector/vector10.hpp> +#include <boost/mpl/equal.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef vector6<int,float,char,float,float,double> types; + typedef mpl::remove< types,float >::type result; + typedef vector3<int,char,double> answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/remove_if.cpp b/src/boost/libs/mpl/test/remove_if.cpp new file mode 100644 index 00000000..bf9d0eae --- /dev/null +++ b/src/boost/libs/mpl/test/remove_if.cpp @@ -0,0 +1,54 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/remove_if.hpp> + +#include <boost/mpl/list/list10_c.hpp> +#include <boost/mpl/list/list10.hpp> +#include <boost/mpl/front_inserter.hpp> +#include <boost/mpl/greater.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/size.hpp> +#include <boost/type_traits/is_float.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list10_c<int,0,1,2,3,4,5,6,7,8,9> numbers; + typedef list5_c<int,4,3,2,1,0>::type answer; + typedef remove_if< + numbers + , greater<_,int_<4> > + , mpl::front_inserter< list0_c<int> > + >::type result; + + MPL_ASSERT_RELATION( size<result>::value, ==, 5 ); + MPL_ASSERT(( equal<result,answer> )); +} + +MPL_TEST_CASE() +{ + typedef list8<int,float,long,float,char,long,double,double> types; + typedef list4<int,long,char,long>::type answer; + typedef reverse_remove_if< + types + , is_float<_> + , mpl::front_inserter< list0<> > + >::type result; + + MPL_ASSERT_RELATION( size<result>::value, ==, 4 ); + MPL_ASSERT(( equal<result,answer> )); +} diff --git a/src/boost/libs/mpl/test/replace.cpp b/src/boost/libs/mpl/test/replace.cpp new file mode 100644 index 00000000..4b3005be --- /dev/null +++ b/src/boost/libs/mpl/test/replace.cpp @@ -0,0 +1,27 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/replace.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,float,char,float,float,double> types; + typedef replace< types,float,double >::type result; + typedef list<int,double,char,double,double,double> answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/replace_if.cpp b/src/boost/libs/mpl/test/replace_if.cpp new file mode 100644 index 00000000..4fc690d9 --- /dev/null +++ b/src/boost/libs/mpl/test/replace_if.cpp @@ -0,0 +1,33 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright John R. Bandela 2000-2002 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/replace_if.hpp> + +#include <boost/mpl/list/list10_c.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/greater.hpp> +#include <boost/mpl/equal_to.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list8_c<int,1,4,5,2,7,5,3,5>::type numbers; + typedef replace_if< numbers, greater<_1,int_<4> >, int_<0> >::type result; + + typedef list8_c<int,1,4,0,2,0,0,3,0>::type answer; + MPL_ASSERT(( equal< answer,result,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/reverse.cpp b/src/boost/libs/mpl/test/reverse.cpp new file mode 100644 index 00000000..69b4a432 --- /dev/null +++ b/src/boost/libs/mpl/test/reverse.cpp @@ -0,0 +1,32 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/reverse.hpp> + +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/at.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list_c<int,9,8,7,6,5,4,3,2,1,0> numbers; + typedef reverse< numbers >::type result; + + typedef range_c<int,0,10> answer; + + MPL_ASSERT(( equal< result,answer,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/same_as.cpp b/src/boost/libs/mpl/test/same_as.cpp new file mode 100644 index 00000000..41a7c573 --- /dev/null +++ b/src/boost/libs/mpl/test/same_as.cpp @@ -0,0 +1,23 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/same_as.hpp> + +#include <boost/mpl/apply.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + MPL_ASSERT(( apply1< same_as<int>,int > )); + MPL_ASSERT_NOT(( apply1< same_as<int>,long > )); +} diff --git a/src/boost/libs/mpl/test/set.cpp b/src/boost/libs/mpl/test/set.cpp new file mode 100644 index 00000000..0710b41b --- /dev/null +++ b/src/boost/libs/mpl/test/set.cpp @@ -0,0 +1,347 @@ + +// Copyright Aleksey Gurtovoy 2003-2007 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/set.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/find.hpp> +#include <boost/mpl/deref.hpp> +#include <boost/mpl/next.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/erase.hpp> +#include <boost/mpl/erase_key.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/clear.hpp> +#include <boost/mpl/has_key.hpp> +#include <boost/mpl/order.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/distance.hpp> +#include <boost/mpl/empty.hpp> +#include <boost/mpl/begin_end.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +// Use templates for testing so that GCC will show us the actual types involved + +template< typename s > +void empty_set_test() +{ + MPL_ASSERT_RELATION( size<s>::value, ==, 0 ); + MPL_ASSERT(( empty<s> )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > )); + + MPL_ASSERT_NOT(( has_key<s,int> )); + MPL_ASSERT_NOT(( has_key<s,char> )); + MPL_ASSERT_NOT(( has_key<s,long> )); + + typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1; + typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2; + typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3; + MPL_ASSERT(( is_same< o1, void_ > )); + MPL_ASSERT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + + typedef BOOST_DEDUCED_TYPENAME begin<s>::type first; + typedef BOOST_DEDUCED_TYPENAME end<s>::type last; + + MPL_ASSERT(( is_same<first, last> )); + MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 0 ); +} + + +template< typename s > +void int_set_test() +{ + MPL_ASSERT_RELATION( size<s>::value, ==, 1 ); + MPL_ASSERT_NOT(( empty<s> )); + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, void_ > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, void_ > )); + + MPL_ASSERT(( has_key<s,int> )); + MPL_ASSERT_NOT(( has_key<s,char> )); + MPL_ASSERT_NOT(( has_key<s,long> )); + + typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1; + typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2; + typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + + typedef BOOST_DEDUCED_TYPENAME begin<s>::type first; + typedef BOOST_DEDUCED_TYPENAME end<s>::type last; + + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME deref<first>::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME next<first>::type, last > )); + + MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 1 ); + MPL_ASSERT(( contains< s, int > )); +} + + +template< typename s > +void int_char_set_test() +{ + MPL_ASSERT_RELATION( size<s>::value, ==, 2 ); + MPL_ASSERT_NOT(( empty<s> )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > )); + + MPL_ASSERT(( has_key<s,char> )); + MPL_ASSERT_NOT(( has_key<s,long> )); + + typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1; + typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2; + typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT_NOT(( is_same< o2, void_ > )); + MPL_ASSERT(( is_same< o3, void_ > )); + MPL_ASSERT_NOT(( is_same< o1, o2 > )); + + typedef BOOST_DEDUCED_TYPENAME begin<s>::type first; + typedef BOOST_DEDUCED_TYPENAME end<s>::type last; + + MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 2 ); + + MPL_ASSERT(( contains< s, int > )); + MPL_ASSERT(( contains< s, char > )); +} + +template< typename s > +void int_char_long_set_test() +{ + MPL_ASSERT_RELATION( size<s>::value, ==, 3 ); + MPL_ASSERT_NOT(( empty<s> )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME clear<s>::type, set0<> > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,int>::type, int > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,char>::type, char > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME at<s,long>::type, long > )); + + MPL_ASSERT(( has_key<s,long> )); + MPL_ASSERT(( has_key<s,int> )); + MPL_ASSERT(( has_key<s,char> )); + + typedef BOOST_DEDUCED_TYPENAME order<s,int>::type o1; + typedef BOOST_DEDUCED_TYPENAME order<s,char>::type o2; + typedef BOOST_DEDUCED_TYPENAME order<s,long>::type o3; + MPL_ASSERT_NOT(( is_same< o1, void_ > )); + MPL_ASSERT_NOT(( is_same< o2, void_ > )); + MPL_ASSERT_NOT(( is_same< o3, void_ > )); + MPL_ASSERT_NOT(( is_same< o1, o2 > )); + MPL_ASSERT_NOT(( is_same< o1, o3 > )); + MPL_ASSERT_NOT(( is_same< o2, o3 > )); + + typedef BOOST_DEDUCED_TYPENAME begin<s>::type first; + typedef BOOST_DEDUCED_TYPENAME end<s>::type last; + MPL_ASSERT_RELATION( (distance<first, last>::value), ==, 3 ); + + MPL_ASSERT(( contains< s, int > )); + MPL_ASSERT(( contains< s, char > )); + MPL_ASSERT(( contains< s, long > )); +} + +template< typename S0, typename S1, typename S2, typename S3 > +void basic_set_test() +{ + empty_set_test<S0>(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key<S1,int>::type >(); + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type + , int + >::type >(); + + empty_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type + , long + >::type + , int + >::type >(); + + + int_set_test<S1>(); + int_set_test< BOOST_DEDUCED_TYPENAME insert<S0,int>::type >(); + + int_set_test< BOOST_DEDUCED_TYPENAME erase_key<S2,char>::type >(); + int_set_test< BOOST_DEDUCED_TYPENAME erase_key< + BOOST_DEDUCED_TYPENAME erase_key<S3,char>::type + , long + >::type >(); + + int_char_set_test<S2>(); + int_char_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert<S0,char>::type + , int + >::type >(); + + int_char_set_test< BOOST_DEDUCED_TYPENAME insert<S1,char>::type >(); + int_char_set_test< BOOST_DEDUCED_TYPENAME erase_key<S3,long>::type >(); + + int_char_long_set_test<S3>(); + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert<S0,char>::type + , long + >::type + , int + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert< + BOOST_DEDUCED_TYPENAME insert<S1,long>::type + , char + >::type >(); + + int_char_long_set_test< BOOST_DEDUCED_TYPENAME insert<S2,long>::type >(); +} + + +template< typename S1, typename S2 > +void numbered_vs_variadic_set_test() +{ + MPL_ASSERT(( is_same< S1, BOOST_DEDUCED_TYPENAME S1::type > )); + MPL_ASSERT(( is_same< BOOST_DEDUCED_TYPENAME S2::type, S1 > )); +} + + +MPL_TEST_CASE() +{ + typedef mpl::set0<> s01; + typedef mpl::set<> s02; + typedef mpl::set1<int> s11; + typedef mpl::set<int> s12; + typedef mpl::set2<int,char> s21; + typedef mpl::set<int,char> s22; + typedef mpl::set<char,int> s23; + typedef mpl::set3<int,char,long> s31; + typedef mpl::set<int,char,long> s32; + typedef mpl::set<int,long,char> s33; + typedef mpl::set<long,char,int> s34; + + numbered_vs_variadic_set_test<s01,s02>(); + numbered_vs_variadic_set_test<s11,s12>(); + numbered_vs_variadic_set_test<s21,s22>(); + numbered_vs_variadic_set_test<s31,s32>(); + + basic_set_test<s01,s11,s21,s31>(); + basic_set_test<s02,s12,s22,s32>(); + basic_set_test<s01,s11,s23,s31>(); + basic_set_test<s01,s11,s23,s33>(); + basic_set_test<s01,s11,s23,s34>(); +} + + +template< typename s > +void empty_set_types_variety_test() +{ + MPL_ASSERT_NOT(( has_key<s,char> )); + MPL_ASSERT_NOT(( has_key<s,int> )); + MPL_ASSERT_NOT(( has_key<s,UDT> )); + MPL_ASSERT_NOT(( has_key<s,incomplete> )); + + MPL_ASSERT_NOT(( has_key<s,char const> )); + MPL_ASSERT_NOT(( has_key<s,int const> )); + MPL_ASSERT_NOT(( has_key<s,UDT const> )); + MPL_ASSERT_NOT(( has_key<s,incomplete const> )); + + MPL_ASSERT_NOT(( has_key<s,int*> )); + MPL_ASSERT_NOT(( has_key<s,UDT*> )); + MPL_ASSERT_NOT(( has_key<s,incomplete*> )); + + MPL_ASSERT_NOT(( has_key<s,int&> )); + MPL_ASSERT_NOT(( has_key<s,UDT&> )); + MPL_ASSERT_NOT(( has_key<s,incomplete&> )); +} + +template< typename s > +void set_types_variety_test() +{ + MPL_ASSERT_RELATION( size<s>::value, ==, 8 ); + + MPL_ASSERT(( has_key<s,char> )); + MPL_ASSERT(( has_key<s,int const> )); + MPL_ASSERT(( has_key<s,long*> )); + MPL_ASSERT(( has_key<s,UDT* const> )); + MPL_ASSERT(( has_key<s,incomplete> )); + MPL_ASSERT(( has_key<s,abstract> )); + MPL_ASSERT(( has_key<s,incomplete volatile&> )); + MPL_ASSERT(( has_key<s,abstract const&> )); + + MPL_ASSERT_NOT(( has_key<s,char const> )); + MPL_ASSERT_NOT(( has_key<s,int> )); + MPL_ASSERT_NOT(( has_key<s,long* const> )); + MPL_ASSERT_NOT(( has_key<s,UDT*> )); + MPL_ASSERT_NOT(( has_key<s,incomplete const> )); + MPL_ASSERT_NOT(( has_key<s,abstract volatile> )); + MPL_ASSERT_NOT(( has_key<s,incomplete&> )); + MPL_ASSERT_NOT(( has_key<s,abstract&> )); +} + + +MPL_TEST_CASE() +{ + empty_set_types_variety_test< set<> >(); + empty_set_types_variety_test< set<>::type >(); + + typedef set< + char,int const,long*,UDT* const,incomplete,abstract + , incomplete volatile&,abstract const& + > s; + + set_types_variety_test<s>(); + set_types_variety_test<s::type>(); +} + + +template <class S> +void find_test() +{ + MPL_ASSERT_RELATION( size<S>::value, ==, 3 ); + + typedef typename end<S>::type not_found; + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,int>::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,long>::type,not_found> )); + BOOST_MPL_ASSERT_NOT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char>::type,not_found> )); + BOOST_MPL_ASSERT(( is_same<BOOST_DEDUCED_TYPENAME find<S,char*>::type,not_found> )); +} + +MPL_TEST_CASE() +{ + typedef mpl::set<int,long,char> s; + find_test<s>(); + find_test<s::type>(); +} + +MPL_TEST_CASE() +{ + typedef insert< set<>, int >::type little_set; + + MPL_ASSERT_RELATION(size<little_set>::value, ==, 1); + MPL_ASSERT_RELATION(size<little_set::type>::value, ==, 1); +} + +MPL_TEST_CASE() +{ + typedef erase_key< set< float, int >, float >::type little_set; + + MPL_ASSERT_RELATION(size<little_set>::value, ==, 1); + MPL_ASSERT_RELATION(size<little_set::type>::value, ==, 1); +} diff --git a/src/boost/libs/mpl/test/set_c.cpp b/src/boost/libs/mpl/test/set_c.cpp new file mode 100644 index 00000000..e34d86de --- /dev/null +++ b/src/boost/libs/mpl/test/set_c.cpp @@ -0,0 +1,106 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/set_c.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/begin_end.hpp> + +#include <boost/mpl/aux_/test.hpp> + +namespace test { namespace { +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) +template< typename S, typename S::value_type k > +struct at_c + : at< S, integral_c<typename S::value_type,k> >::type +{ +}; +#else +template< typename S, long k > +struct at_c + : aux::msvc_eti_base< + at< S, integral_c<typename S::value_type,k> > + > +{ +}; +#endif +}} + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1200) +MPL_TEST_CASE() +{ + typedef set_c<bool,true>::type s1; + typedef set_c<bool,false>::type s2; + typedef set_c<bool,true,false>::type s3; + + MPL_ASSERT_RELATION( size<s1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<s2>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<s3>::value, ==, 2 ); + + MPL_ASSERT(( is_same< s1::value_type, bool > )); + MPL_ASSERT(( is_same< s3::value_type, bool > )); + MPL_ASSERT(( is_same< s2::value_type, bool > )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + MPL_ASSERT_RELATION( ( test::at_c<s1,true>::value ), ==, true ); + MPL_ASSERT_RELATION( ( test::at_c<s2,false>::value ), ==, false ); + MPL_ASSERT_RELATION( ( test::at_c<s3,true>::value ), ==, true ); + MPL_ASSERT_RELATION( ( test::at_c<s3,false>::value ), ==, false ); + + MPL_ASSERT(( is_same< test::at_c<s1,false>::type, void_ > )); + MPL_ASSERT(( is_same< test::at_c<s2,true>::type, void_ > )); +#endif + + typedef begin<s1>::type first1; + typedef end<s1>::type last1; + MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 ); + + typedef begin<s2>::type first2; + typedef end<s2>::type last2; + MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 1 ); + + typedef begin<s3>::type first3; + typedef end<s3>::type last3; + MPL_ASSERT_RELATION( (distance<first3, last3>::value), ==, 2 ); +} +#endif + +MPL_TEST_CASE() +{ + typedef set_c<char,'a'>::type s1; + typedef set_c<char,'a','b','c','d','e','f','g','h'>::type s2; + + MPL_ASSERT_RELATION( size<s1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<s2>::value, ==, 8 ); + + MPL_ASSERT(( is_same< s1::value_type, char > )); + MPL_ASSERT(( is_same< s2::value_type, char > )); + +#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) + MPL_ASSERT_RELATION( ( test::at_c<s1,'a'>::value ), ==, 'a' ); + MPL_ASSERT_RELATION( ( test::at_c<s2,'a'>::value ), ==, 'a' ); + MPL_ASSERT_RELATION( ( test::at_c<s2,'d'>::value ), ==, 'd' ); + MPL_ASSERT_RELATION( ( test::at_c<s2,'h'>::value ), ==, 'h' ); + + MPL_ASSERT(( is_same< test::at_c<s1,'z'>::type, void_ > )); + MPL_ASSERT(( is_same< test::at_c<s2,'k'>::type, void_ > )); +#endif + + typedef begin<s1>::type first1; + typedef end<s1>::type last1; + MPL_ASSERT_RELATION( (distance<first1, last1>::value), ==, 1 ); + + typedef begin<s2>::type first2; + typedef end<s2>::type last2; + MPL_ASSERT_RELATION( (distance<first2, last2>::value), ==, 8 ); +} diff --git a/src/boost/libs/mpl/test/single_view.cpp b/src/boost/libs/mpl/test/single_view.cpp new file mode 100644 index 00000000..18169d35 --- /dev/null +++ b/src/boost/libs/mpl/test/single_view.cpp @@ -0,0 +1,43 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/single_view.hpp> +#include <boost/mpl/advance.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/begin_end.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef single_view<int> view; + typedef begin<view>::type first; + typedef end<view>::type last; + + MPL_ASSERT(( is_same< deref<first>::type, int > )); + MPL_ASSERT(( is_same< next<first>::type, last > )); + MPL_ASSERT(( is_same< prior<last>::type, first > )); + + MPL_ASSERT(( is_same< mpl::advance<first, int_<0> >::type, first > )); + MPL_ASSERT(( is_same< mpl::advance<first, int_<1> >::type, last > )); + MPL_ASSERT(( is_same< mpl::advance<last, int_<0> >::type, last > )); + MPL_ASSERT(( is_same< mpl::advance<last, int_<-1> >::type, first > )); + + MPL_ASSERT_RELATION( (mpl::distance<first,first>::value), ==, 0 ); + MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 1 ); + MPL_ASSERT_RELATION( (mpl::distance<last,last>::value), ==, 0 ); + + MPL_ASSERT_RELATION( size<view>::value, ==, 1 ); + + MPL_ASSERT(( equal< view, view::type > )); +} diff --git a/src/boost/libs/mpl/test/size.cpp b/src/boost/libs/mpl/test/size.cpp new file mode 100644 index 00000000..0c80711e --- /dev/null +++ b/src/boost/libs/mpl/test/size.cpp @@ -0,0 +1,26 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/size.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<> empty_list; + typedef list<char,short,int,long> list; + + MPL_ASSERT_RELATION( size<empty_list>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<list>::value, ==, 4 ); +} diff --git a/src/boost/libs/mpl/test/size_t.cpp b/src/boost/libs/mpl/test/size_t.cpp new file mode 100644 index 00000000..c53194ba --- /dev/null +++ b/src/boost/libs/mpl/test/size_t.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +// Necessary to overcome a strange name lookup bug in GCC 3.3 and 4.0 for Mac OS X +#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ <= 4) +# include <cassert> +#endif + +#include <boost/mpl/size_t.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> + +#include "integral_wrapper_test.hpp" + +MPL_TEST_CASE() +{ +# define WRAPPER(T, i) mpl::size_t<i> + BOOST_PP_REPEAT_FROM_TO(1, 11, INTEGRAL_WRAPPER_TEST, std::size_t) +} diff --git a/src/boost/libs/mpl/test/sizeof.cpp b/src/boost/libs/mpl/test/sizeof.cpp new file mode 100644 index 00000000..21c0ce02 --- /dev/null +++ b/src/boost/libs/mpl/test/sizeof.cpp @@ -0,0 +1,28 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/sizeof.hpp> +#include <boost/mpl/aux_/test.hpp> + +struct my +{ + char a[100]; +}; + +MPL_TEST_CASE() +{ + MPL_ASSERT_RELATION( sizeof_<char>::value, ==, sizeof(char) ); + MPL_ASSERT_RELATION( sizeof_<int>::value, ==, sizeof(int) ); + MPL_ASSERT_RELATION( sizeof_<double>::value, ==, sizeof(double) ); + MPL_ASSERT_RELATION( sizeof_<my>::value, ==, sizeof(my) ); +} diff --git a/src/boost/libs/mpl/test/sort.cpp b/src/boost/libs/mpl/test/sort.cpp new file mode 100644 index 00000000..e461f703 --- /dev/null +++ b/src/boost/libs/mpl/test/sort.cpp @@ -0,0 +1,27 @@ + +// Copyright Aleksey Gurtovoy 2004 +// Copyright Eric Friedman 2002-2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +#include <boost/mpl/sort.hpp> + +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/equal_to.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list_c<int, 3, 4, 0, -5, 8, -1, 7>::type numbers; + typedef list_c<int, -5, -1, 0, 3, 4, 7, 8>::type manual_result; + + typedef sort< numbers >::type result; + + MPL_ASSERT(( equal< result,manual_result,equal_to<_1,_2> > )); +} diff --git a/src/boost/libs/mpl/test/stable_partition.cpp b/src/boost/libs/mpl/test/stable_partition.cpp new file mode 100644 index 00000000..e72d453a --- /dev/null +++ b/src/boost/libs/mpl/test/stable_partition.cpp @@ -0,0 +1,47 @@ + +// Copyright Aleksey Gurtovoy 2004 +// Copyright Eric Friedman 2003 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/stable_partition.hpp> + +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/comparison.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +typedef vector_c<int,3,4,0,-5,8,-1,7>::type numbers; +typedef vector_c<int,0,-5,-1>::type manual_first; +typedef vector_c<int,3,4,8,7>::type manual_second; + +MPL_TEST_CASE() +{ + typedef stable_partition< + numbers + , less< _, int_<3> > + >::type result; + + MPL_ASSERT(( equal< result::first,manual_first > )); + MPL_ASSERT(( equal< result::second,manual_second > )); +} + +MPL_TEST_CASE() +{ + typedef stable_partition< + numbers + , greater_equal< _, int_<3> > + >::type result; + + MPL_ASSERT(( equal< result::first,manual_second > )); + MPL_ASSERT(( equal< result::second,manual_first > )); +} diff --git a/src/boost/libs/mpl/test/string.cpp b/src/boost/libs/mpl/test/string.cpp new file mode 100644 index 00000000..57b5979d --- /dev/null +++ b/src/boost/libs/mpl/test/string.cpp @@ -0,0 +1,516 @@ + +// Copyright Eric Niebler 2009 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id: string.cpp 49240 2009-04-01 09:21:07Z eric_niebler $ +// $Date: 2009-04-01 02:21:07 -0700 (Wed, 1 Apr 2009) $ +// $Revision: 49240 $ + +#include <string> +#include <cstring> +#include <iostream> + +#include <boost/mpl/string.hpp> + +#include <boost/mpl/at.hpp> +#include <boost/mpl/back.hpp> +#include <boost/mpl/empty.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/erase.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/advance.hpp> +#include <boost/mpl/for_each.hpp> +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/pop_back.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/detail/lightweight_test.hpp> + +namespace mpl = boost::mpl; + +// Accept a string as a template parameter! +template<char const *sz> +struct greeting +{ + std::string say_hello() const + { + return sz; + } +}; + +struct push_char +{ + push_char(std::string &str) + : str_(&str) + {} + + void operator()(char ch) const + { + this->str_->push_back(ch); + } + + std::string *str_; +}; + +int main() +{ + // Test mpl::size of strings + { + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> full; + + BOOST_MPL_ASSERT_RELATION(0, ==, (mpl::size<mpl::string<> >::value)); + BOOST_MPL_ASSERT_RELATION(1, ==, (mpl::size<mpl::string<'a'> >::value)); + BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size<mpl::string<'ab'> >::value)); + BOOST_MPL_ASSERT_RELATION(2, ==, (mpl::size<mpl::string<'a','b'> >::value)); + BOOST_MPL_ASSERT_RELATION(4, ==, (mpl::size<mpl::string<'abcd'> >::value)); + BOOST_MPL_ASSERT_RELATION(5, ==, (mpl::size<mpl::string<'abcd','e'> >::value)); + BOOST_MPL_ASSERT_RELATION(31, ==, (mpl::size<almost_full>::value)); + BOOST_MPL_ASSERT_RELATION(32, ==, (mpl::size<full>::value)); + } + + // Test mpl::begin and mpl::end with strings + { + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> full; + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin<mpl::string<> >::type + , mpl::end<mpl::string<> >::type + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin<mpl::string<'a'> >::type + , mpl::string_iterator<mpl::string<'a'>, 0, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end<mpl::string<'a'> >::type + , mpl::string_iterator<mpl::string<'a'>, 1, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin<almost_full>::type + , mpl::string_iterator<almost_full, 0, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end<almost_full>::type + , mpl::string_iterator<almost_full, 8, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::begin<full>::type + , mpl::string_iterator<full, 0, 0> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::end<full>::type + , mpl::string_iterator<full, 8, 0> + > + )); + } + + // testing push_back + { + typedef mpl::push_back<mpl::string<>, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >)); + + typedef mpl::push_back<t1, mpl::char_<'b'> >::type t2; + BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ab'> >)); + + typedef mpl::push_back<t2, mpl::char_<'c'> >::type t3; + BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'abc'> >)); + + typedef mpl::push_back<t3, mpl::char_<'d'> >::type t4; + BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'abcd'> >)); + + typedef mpl::push_back<t4, mpl::char_<'e'> >::type t5; + BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'abcd','e'> >)); + + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::push_back<almost_full, mpl::char_<'X'> >::type t6; + BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >)); + } + + // Test mpl::next + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::begin<s>::type i0; + BOOST_MPL_ASSERT((boost::is_same<i0, mpl::string_iterator<s,0,0> >)); + + typedef mpl::next<i0>::type i1; + BOOST_MPL_ASSERT((boost::is_same<i1, mpl::string_iterator<s,1,0> >)); + + typedef mpl::next<i1>::type i2; + BOOST_MPL_ASSERT((boost::is_same<i2, mpl::string_iterator<s,1,1> >)); + + typedef mpl::next<i2>::type i3; + BOOST_MPL_ASSERT((boost::is_same<i3, mpl::string_iterator<s,2,0> >)); + + typedef mpl::next<i3>::type i4; + BOOST_MPL_ASSERT((boost::is_same<i4, mpl::string_iterator<s,2,1> >)); + + typedef mpl::next<i4>::type i5; + BOOST_MPL_ASSERT((boost::is_same<i5, mpl::string_iterator<s,2,2> >)); + + typedef mpl::next<i5>::type i6; + BOOST_MPL_ASSERT((boost::is_same<i6, mpl::string_iterator<s,3,0> >)); + + typedef mpl::next<i6>::type i7; + BOOST_MPL_ASSERT((boost::is_same<i7, mpl::string_iterator<s,3,1> >)); + + typedef mpl::next<i7>::type i8; + BOOST_MPL_ASSERT((boost::is_same<i8, mpl::string_iterator<s,3,2> >)); + + typedef mpl::next<i8>::type i9; + BOOST_MPL_ASSERT((boost::is_same<i9, mpl::string_iterator<s,3,3> >)); + + typedef mpl::next<i9>::type i10; + BOOST_MPL_ASSERT((boost::is_same<i10, mpl::string_iterator<s,4,0> >)); + + BOOST_MPL_ASSERT((boost::is_same<i10, mpl::end<s>::type>)); + } + + // Test mpl::prior + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::end<s>::type i10; + BOOST_MPL_ASSERT((boost::is_same<i10, mpl::string_iterator<s,4,0> >)); + + typedef mpl::prior<i10>::type i9; + BOOST_MPL_ASSERT((boost::is_same<i9, mpl::string_iterator<s,3,3> >)); + + typedef mpl::prior<i9>::type i8; + BOOST_MPL_ASSERT((boost::is_same<i8, mpl::string_iterator<s,3,2> >)); + + typedef mpl::prior<i8>::type i7; + BOOST_MPL_ASSERT((boost::is_same<i7, mpl::string_iterator<s,3,1> >)); + + typedef mpl::prior<i7>::type i6; + BOOST_MPL_ASSERT((boost::is_same<i6, mpl::string_iterator<s,3,0> >)); + + typedef mpl::prior<i6>::type i5; + BOOST_MPL_ASSERT((boost::is_same<i5, mpl::string_iterator<s,2,2> >)); + + typedef mpl::prior<i5>::type i4; + BOOST_MPL_ASSERT((boost::is_same<i4, mpl::string_iterator<s,2,1> >)); + + typedef mpl::prior<i4>::type i3; + BOOST_MPL_ASSERT((boost::is_same<i3, mpl::string_iterator<s,2,0> >)); + + typedef mpl::prior<i3>::type i2; + BOOST_MPL_ASSERT((boost::is_same<i2, mpl::string_iterator<s,1,1> >)); + + typedef mpl::prior<i2>::type i1; + BOOST_MPL_ASSERT((boost::is_same<i1, mpl::string_iterator<s,1,0> >)); + + typedef mpl::prior<i1>::type i0; + BOOST_MPL_ASSERT((boost::is_same<i0, mpl::string_iterator<s,0,0> >)); + + BOOST_MPL_ASSERT((boost::is_same<i0, mpl::begin<s>::type>)); + } + + // Test mpl::deref + { + typedef mpl::string<'a','bc','def','ghij'> s; + + typedef mpl::begin<s>::type i0; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i0>::type, mpl::char_<'a'> >)); + + typedef mpl::next<i0>::type i1; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i1>::type, mpl::char_<'b'> >)); + + typedef mpl::next<i1>::type i2; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i2>::type, mpl::char_<'c'> >)); + + typedef mpl::next<i2>::type i3; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i3>::type, mpl::char_<'d'> >)); + + typedef mpl::next<i3>::type i4; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i4>::type, mpl::char_<'e'> >)); + + typedef mpl::next<i4>::type i5; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i5>::type, mpl::char_<'f'> >)); + + typedef mpl::next<i5>::type i6; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i6>::type, mpl::char_<'g'> >)); + + typedef mpl::next<i6>::type i7; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i7>::type, mpl::char_<'h'> >)); + + typedef mpl::next<i7>::type i8; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i8>::type, mpl::char_<'i'> >)); + + typedef mpl::next<i8>::type i9; + BOOST_MPL_ASSERT((boost::is_same<mpl::deref<i9>::type, mpl::char_<'j'> >)); + } + + // testing push_back + { + typedef mpl::push_back<mpl::string<>, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >)); + + typedef mpl::push_back<t1, mpl::char_<'b'> >::type t2; + BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ab'> >)); + + typedef mpl::push_back<t2, mpl::char_<'c'> >::type t3; + BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'abc'> >)); + + typedef mpl::push_back<t3, mpl::char_<'d'> >::type t4; + BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'abcd'> >)); + + typedef mpl::push_back<t4, mpl::char_<'e'> >::type t5; + BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'abcd','e'> >)); + + typedef mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> almost_full; + typedef mpl::push_back<almost_full, mpl::char_<'X'> >::type t6; + BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >)); + + typedef mpl::string<'a','a','a','a','a','a','a','aaaa'> must_repack; + typedef mpl::push_back<must_repack, mpl::char_<'X'> >::type t7; + BOOST_MPL_ASSERT((boost::is_same<t7, mpl::string<'aaaa','aaaa','aaaX'> >)); + } + + BOOST_MPL_ASSERT((mpl::empty<mpl::string<> >)); + BOOST_MPL_ASSERT_NOT((mpl::empty<mpl::string<'hi!'> >)); + + // testing push_front + { + typedef mpl::push_front<mpl::string<>, mpl::char_<'a'> >::type t1; + BOOST_MPL_ASSERT((boost::is_same<t1, mpl::string<'a'> >)); + + typedef mpl::push_front<t1, mpl::char_<'b'> >::type t2; + BOOST_MPL_ASSERT((boost::is_same<t2, mpl::string<'ba'> >)); + + typedef mpl::push_front<t2, mpl::char_<'c'> >::type t3; + BOOST_MPL_ASSERT((boost::is_same<t3, mpl::string<'cba'> >)); + + typedef mpl::push_front<t3, mpl::char_<'d'> >::type t4; + BOOST_MPL_ASSERT((boost::is_same<t4, mpl::string<'dcba'> >)); + + typedef mpl::push_front<t4, mpl::char_<'e'> >::type t5; + BOOST_MPL_ASSERT((boost::is_same<t5, mpl::string<'e','dcba'> >)); + + typedef mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> almost_full; + typedef mpl::push_front<almost_full, mpl::char_<'X'> >::type t6; + BOOST_MPL_ASSERT((boost::is_same<t6, mpl::string<'Xaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >)); + + typedef mpl::string<'aaaa','a','a','a','a','a','a','a'> must_repack; + typedef mpl::push_front<must_repack, mpl::char_<'X'> >::type t7; + BOOST_MPL_ASSERT((boost::is_same<t7, mpl::string<'Xaaa','aaaa','aaaa'> >)); + } + + // Test c_str<> + BOOST_TEST(0 == std::strcmp( + mpl::c_str<mpl::string<> >::value + , "" + )); + + BOOST_TEST(0 == std::strcmp( + mpl::c_str<mpl::string<'Hell','o wo','rld!'> >::value + , "Hell" "o wo" "rld!" + )); + + BOOST_TEST(0 == std::strcmp( + mpl::c_str<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaX'> >::value + , "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaa" "aaaX" + )); + + // test using a string as a template parameter + greeting<mpl::c_str<mpl::string<'Hell','o wo','rld!'> >::value> g; + BOOST_TEST("Hello world!" == g.say_hello()); + + std::string result; + mpl::for_each<mpl::string<'Hell','o wo','rld!'> >(push_char(result)); + BOOST_TEST("Hello world!" == result); + + BOOST_TEST(('h' == mpl::front<mpl::string<'hi!'> >::type())); + BOOST_TEST(('!' == mpl::back<mpl::string<'hi!'> >::type())); + + // back-inserter with copy + typedef mpl::vector_c<char, 'a','b','c','d','e'> rgc; + BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str<rgc>::value)); + typedef mpl::copy<rgc, mpl::back_inserter<mpl::string<> > >::type str; + BOOST_TEST(0 == std::strcmp("abcde", mpl::c_str<str>::value)); + + // test insert_range and erase + { + typedef mpl::string<'Hell','o wo','rld!'> hello; + typedef mpl::advance_c<mpl::begin<hello>::type, 5>::type where; + typedef mpl::string<' cru','el'> cruel; + typedef mpl::insert_range<hello, where, cruel>::type hello_cruel; + BOOST_TEST(0 == std::strcmp("Hello cruel world!", mpl::c_str<hello_cruel>::value)); + + typedef mpl::erase<hello, mpl::begin<hello>::type, where>::type erased1; + BOOST_TEST(0 == std::strcmp(" world!", mpl::c_str<erased1>::value)); + } + + // test pop_front + { + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'a'> >::type + , mpl::string<> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'ab'> >::type + , mpl::string<'b'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'abc'> >::type + , mpl::string<'bc'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'abcd'> >::type + , mpl::string<'bcd'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'abcd','e'> >::type + , mpl::string<'bcd','e'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'d','e'> >::type + , mpl::string<'e'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_front<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >::type + , mpl::string<'aaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> + > + )); + } + + // test pop_back + { + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'a'> >::type + , mpl::string<> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'ab'> >::type + , mpl::string<'a'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'abc'> >::type + , mpl::string<'ab'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'abcd'> >::type + , mpl::string<'abc'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'abcd','e'> >::type + , mpl::string<'abcd'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'d','e'> >::type + , mpl::string<'d'> + > + )); + + BOOST_MPL_ASSERT(( + boost::is_same< + mpl::pop_back<mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa'> >::type + , mpl::string<'aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaaa','aaa'> + > + )); + } + + { + BOOST_TEST(( + mpl::at_c< + mpl::string<'\x7f'> + , 0 + >::type::value == (char)0x7f + )); + + BOOST_TEST(( + mpl::at_c< + mpl::string<'\x80'> + , 0 + >::type::value == (char)0x80 + )); + + BOOST_TEST(( + mpl::at_c< + mpl::string< + mpl::at_c< + mpl::string<'\x7f'> + , 0 + >::type::value + > + , 0 + >::type::value == (char)0x7f + )); + + BOOST_TEST(( + mpl::at_c< + mpl::string< + mpl::at_c< + mpl::string<'\x80'> + , 0 + >::type::value + > + , 0 + >::type::value == (char)0x80 + )); + } + + return boost::report_errors(); +} diff --git a/src/boost/libs/mpl/test/transform.cpp b/src/boost/libs/mpl/test/transform.cpp new file mode 100644 index 00000000..8df17f20 --- /dev/null +++ b/src/boost/libs/mpl/test/transform.cpp @@ -0,0 +1,51 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/transform.hpp> + +#include <boost/mpl/list.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/plus.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/mpl/aux_/config/gcc.hpp> +#include <boost/mpl/aux_/config/workaround.hpp> + +#include <boost/type_traits/add_pointer.hpp> + + +MPL_TEST_CASE() +{ + typedef list<char,short,int,long,float,double> types; + typedef list<char*,short*,int*,long*,float*,double*> pointers; + + typedef transform1< types,add_pointer<_1> >::type result; + MPL_ASSERT(( equal<result,pointers> )); +} + +MPL_TEST_CASE() +{ + typedef list_c<long,0,2,4,6,8,10> evens; + typedef list_c<long,2,3,5,7,11,13> primes; + typedef list_c<long,2,5,9,13,19,23> sums; + + typedef transform2< evens, primes, plus<> >::type result; + MPL_ASSERT(( equal< result,sums,equal_to<_1,_2> > )); + +#if !defined(BOOST_MPL_CFG_NO_HAS_XXX) + typedef transform< evens, primes, plus<> >::type result2; + MPL_ASSERT(( is_same<result2,result> )); +#endif +} diff --git a/src/boost/libs/mpl/test/transform_view.cpp b/src/boost/libs/mpl/test/transform_view.cpp new file mode 100644 index 00000000..ff8fe6b5 --- /dev/null +++ b/src/boost/libs/mpl/test/transform_view.cpp @@ -0,0 +1,40 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/transform_view.hpp> + +#include <boost/mpl/max_element.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/sizeof.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,long,char,char[50],double> types; + typedef list< + sizeof_<int>::type, + sizeof_<long>::type, + sizeof_<char>::type, + sizeof_<char[50]>::type, + sizeof_<double>::type + > sizes; + + MPL_ASSERT(( equal< transform_view< types, sizeof_<_> >::type,sizes > )); + + typedef max_element< + transform_view< types, sizeof_<_> > + >::type iter; + + MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 50 ); +} diff --git a/src/boost/libs/mpl/test/unique.cpp b/src/boost/libs/mpl/test/unique.cpp new file mode 100644 index 00000000..2e1baa71 --- /dev/null +++ b/src/boost/libs/mpl/test/unique.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// Copyright David Abrahams 2003-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/unique.hpp> +#include <boost/mpl/list.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/type_traits/is_same.hpp> + +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list<int,float,float,char,int,int,int,double> types; + typedef unique< types, is_same<_1,_2> >::type result; + + typedef list<int,float,char,int,double>::type answer; + MPL_ASSERT(( equal< result,answer > )); +} diff --git a/src/boost/libs/mpl/test/unpack_args.cpp b/src/boost/libs/mpl/test/unpack_args.cpp new file mode 100644 index 00000000..d506535e --- /dev/null +++ b/src/boost/libs/mpl/test/unpack_args.cpp @@ -0,0 +1,26 @@ + +// Copyright Aleksey Gurtovoy 2002-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/unpack_args.hpp> + +#include <boost/mpl/vector/vector10.hpp> +#include <boost/mpl/aux_/test.hpp> +#include <boost/type_traits/is_same.hpp> + +MPL_TEST_CASE() +{ + MPL_ASSERT(( apply1< + unpack_args< is_same<_1,_2> > + , vector2<int,int> + > )); +} diff --git a/src/boost/libs/mpl/test/upper_bound.cpp b/src/boost/libs/mpl/test/upper_bound.cpp new file mode 100644 index 00000000..7d6ea3bb --- /dev/null +++ b/src/boost/libs/mpl/test/upper_bound.cpp @@ -0,0 +1,29 @@ + +// Copyright Aleksey Gurtovoy 2001-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/upper_bound.hpp> + +#include <boost/mpl/distance.hpp> +#include <boost/mpl/list_c.hpp> +#include <boost/mpl/less.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/aux_/test.hpp> + +MPL_TEST_CASE() +{ + typedef list_c<int,1,2,3,3,3,5,8> numbers; + typedef upper_bound< numbers, int_<3> >::type iter; + + MPL_ASSERT_RELATION( (mpl::distance< begin<numbers>::type,iter >::value), ==, 5 ); + MPL_ASSERT_RELATION( deref<iter>::type::value, ==, 5 ); +} diff --git a/src/boost/libs/mpl/test/vector.cpp b/src/boost/libs/mpl/test/vector.cpp new file mode 100644 index 00000000..e1f6e0cb --- /dev/null +++ b/src/boost/libs/mpl/test/vector.cpp @@ -0,0 +1,124 @@ + +// Copyright Aleksey Gurtovoy 2000-2005 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/vector.hpp> +#include <boost/mpl/vector/vector10.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/push_back.hpp> +#include <boost/mpl/pop_back.hpp> +#include <boost/mpl/push_front.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/back.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/empty.hpp> + +#include <boost/mpl/aux_/test.hpp> + + +MPL_TEST_CASE() +{ + typedef vector0<> v0; + typedef vector1<char> v1; + typedef vector2<char,long> v2; + typedef vector9<char,char,char,char,char,char,char,char,int> v9; + + MPL_ASSERT(( equal< v0,v0::type > )); + MPL_ASSERT(( equal< v1,v1::type > )); + MPL_ASSERT(( equal< v2,v2::type > )); + MPL_ASSERT(( equal< v9,v9::type > )); + + MPL_ASSERT_RELATION( size<v0>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<v1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<v2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<v9>::value, ==, 9 ); + + MPL_ASSERT(( empty<v0> )); + MPL_ASSERT_NOT(( empty<v1> )); + MPL_ASSERT_NOT(( empty<v2> )); + MPL_ASSERT_NOT(( empty<v9> )); + + MPL_ASSERT(( is_same< front<v1>::type,char > )); + MPL_ASSERT(( is_same< back<v1>::type,char > )); + MPL_ASSERT(( is_same< front<v2>::type,char > )); + MPL_ASSERT(( is_same< back<v2>::type,long > )); + MPL_ASSERT(( is_same< front<v9>::type,char > )); + MPL_ASSERT(( is_same< back<v9>::type,int > )); +} + + +MPL_TEST_CASE() +{ + typedef vector2<char,long> v2; + + typedef begin<v2>::type i1; + typedef next<i1>::type i2; + typedef next<i2>::type i3; + + MPL_ASSERT(( is_same<deref<i1>::type,char> )); + MPL_ASSERT(( is_same<deref<i2>::type,long> )); + MPL_ASSERT(( is_same< i3, end<v2>::type > )); +} + +MPL_TEST_CASE() +{ + typedef vector0<> v0; + + typedef push_back<v0,int>::type v1; + typedef push_front<v1,char>::type v2; + typedef push_back<v2,long>::type v3; + + MPL_ASSERT(( is_same< back<v1>::type,int > )); + MPL_ASSERT(( is_same< back<v2>::type,int > )); + MPL_ASSERT(( is_same< front<v2>::type,char > )); + MPL_ASSERT(( is_same< back<v3>::type,long > )); + + MPL_ASSERT(( equal< v1,v1::type > )); + MPL_ASSERT(( equal< v2,v2::type > )); + MPL_ASSERT(( equal< v3,v3::type > )); +} + +MPL_TEST_CASE() +{ + typedef vector9<char,bool,char,char,char,char,bool,long,int> v9; + + typedef pop_back<v9>::type v8; + typedef pop_front<v8>::type v7; + + MPL_ASSERT(( is_same< back<v9>::type,int > )); + MPL_ASSERT(( is_same< back<v8>::type,long > )); + MPL_ASSERT(( is_same< back<v7>::type,long > )); + MPL_ASSERT(( is_same< front<v7>::type,bool > )); + + MPL_ASSERT(( equal< v9,v9::type > )); + MPL_ASSERT(( equal< v8,v8::type > )); + MPL_ASSERT(( equal< v7,v7::type > )); +} + +MPL_TEST_CASE() +{ + typedef vector<> v0; + typedef vector<char> v1; + typedef vector<char,long> v2; + typedef vector<char,char,char,char,char,char,char,char,int> v9; + + MPL_ASSERT(( equal< v0,v0::type > )); + MPL_ASSERT(( equal< v1,v1::type > )); + MPL_ASSERT(( equal< v2,v2::type > )); + MPL_ASSERT(( equal< v9,v9::type > )); + + MPL_ASSERT_RELATION( size<v0>::value, ==, 0 ); + MPL_ASSERT_RELATION( size<v1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<v2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<v9>::value, ==, 9 ); +} diff --git a/src/boost/libs/mpl/test/vector_c.cpp b/src/boost/libs/mpl/test/vector_c.cpp new file mode 100644 index 00000000..fbff9ea3 --- /dev/null +++ b/src/boost/libs/mpl/test/vector_c.cpp @@ -0,0 +1,66 @@ + +// Copyright Aleksey Gurtovoy 2000-2004 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/vector_c.hpp> +#include <boost/mpl/front.hpp> +#include <boost/mpl/size.hpp> + +#include <boost/mpl/aux_/test.hpp> + +#if !BOOST_WORKAROUND(BOOST_MSVC, <=1200) +MPL_TEST_CASE() +{ + typedef vector_c<bool,true>::type v1; + typedef vector_c<bool,false>::type v2; + + MPL_ASSERT(( is_same< v1::value_type, bool > )); + MPL_ASSERT(( is_same< v2::value_type, bool > )); + + MPL_ASSERT_RELATION( front<v1>::type::value, ==, true ); + MPL_ASSERT_RELATION( front<v2>::type::value, ==, false ); +} +#endif + +MPL_TEST_CASE() +{ + typedef vector_c<int,-1> v1; + typedef vector_c<int,0,1> v2; + typedef vector_c<int,1,2,3> v3; + + MPL_ASSERT(( is_same< v1::value_type, int > )); + MPL_ASSERT(( is_same< v2::value_type, int > )); + MPL_ASSERT(( is_same< v3::value_type, int > )); + + MPL_ASSERT_RELATION( size<v1>::value, ==, 1 ); + MPL_ASSERT_RELATION( size<v2>::value, ==, 2 ); + MPL_ASSERT_RELATION( size<v3>::value, ==, 3 ); + + MPL_ASSERT_RELATION( front<v1>::type::value, ==, -1 ); + MPL_ASSERT_RELATION( front<v2>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front<v3>::type::value, ==, 1 ); +} + +MPL_TEST_CASE() +{ + typedef vector_c<unsigned,0> v1; + typedef vector_c<unsigned,1,2> v2; + + MPL_ASSERT(( is_same< v1::value_type, unsigned > )); + MPL_ASSERT(( is_same< v2::value_type, unsigned > )); + + MPL_ASSERT_RELATION( size<v1>::type::value, ==, 1 ); + MPL_ASSERT_RELATION( size<v2>::type::value, ==, 2 ); + + MPL_ASSERT_RELATION( front<v1>::type::value, ==, 0 ); + MPL_ASSERT_RELATION( front<v2>::type::value, ==, 1 ); +} diff --git a/src/boost/libs/mpl/test/zip_view.cpp b/src/boost/libs/mpl/test/zip_view.cpp new file mode 100644 index 00000000..a8d9b03c --- /dev/null +++ b/src/boost/libs/mpl/test/zip_view.cpp @@ -0,0 +1,45 @@ + +// Copyright Aleksey Gurtovoy 2002-2010 +// +// Distributed under 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) +// +// See http://www.boost.org/libs/mpl for documentation. + +// $Id$ +// $Date$ +// $Revision$ + +#include <boost/mpl/zip_view.hpp> + +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/filter_view.hpp> +#include <boost/mpl/range_c.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/at.hpp> +#include <boost/mpl/equal.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/unpack_args.hpp> +#include <boost/mpl/math/is_even.hpp> + +#include <boost/mpl/aux_/test.hpp> + +#include <boost/type_traits/is_same.hpp> + + +MPL_TEST_CASE() +{ + typedef transform_view< + zip_view< vector< range_c<int,0,10>, range_c<int,10,20> > > + , unpack_args< plus<> > + > result; + + MPL_ASSERT(( equal< + result + , filter_view< range_c<int,10,30>, is_even<_> > + , equal_to<_,_> + > )); + + MPL_ASSERT(( boost::is_same< zip_view<vector<> >, zip_view<vector<> >::type > )); +} |