/*-----------------------------------------------------------------------------+ Interval Container Library Author: Joachim Faulhaber Copyright (c) 2007-2010: Joachim Faulhaber Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin +------------------------------------------------------------------------------+ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENCE.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +-----------------------------------------------------------------------------*/ /** Example static_interval.cpp \file static_interval.cpp \brief Intervals with static interval bounds. Intervals types with static or fixed interval bounds. Statically bounded intervals use up to 33% less memory than dynamically bounded ones. Of the four possible statically bounded intervals types right_open_intervals are the most important ones. We can switch the library default to statically bounded intervals by defining BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS. \include static_interval_/static_interval.cpp */ //[example_static_interval #include #include #include #include // We can change the library default for the interval types by defining #define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS // prior to other inluces from the icl. // The interval type that is automatically used with interval // containers then is the statically bounded right_open_interval. #include #include // The statically bounded interval type 'right_open_interval' // is indirectly included via interval containers. #include "../toytime.hpp" #include using namespace std; using namespace boost; using namespace boost::icl; int main() { cout << ">> Interval Container Library: Sample static_interval.cpp <<\n"; cout << "------------------------------------------------------------\n"; // Statically bounded intervals are the user defined library default for // interval parameters in interval containers now. BOOST_STATIC_ASSERT(( boost::is_same< interval_set::interval_type , right_open_interval >::value )); BOOST_STATIC_ASSERT(( boost::is_same< interval_set::interval_type , right_open_interval >::value )); // As we can see the library default both for discrete and continuous // domain_types T is 'right_open_interval'. // The user defined library default for intervals is also available via // the template 'interval': BOOST_STATIC_ASSERT(( boost::is_same< interval::type , right_open_interval >::value )); // Again we are declaring and initializing the four test intervals that have been used // in the example 'interval' and 'dynamic_interval' interval::type int_interval = interval::right_open(3, 8); // shifted the upper bound interval::type sqrt_interval = interval::right_open(1/sqrt(2.0), sqrt(2.0)); // Interval ("Barcelona", "Boston"] can not be represented because there is no 'steppable next' on // lower bound "Barcelona". Ok. this is a different interval: interval::type city_interval = interval::right_open("Barcelona", "Boston"); // Toy Time is discrete again so we can transfrom open(Time(monday,8,30), Time(monday,17,20)) // to right_open(Time(monday,8,31), Time(monday,17,20)) interval