1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. 6 7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library 8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. 9 10 // Use, modification and distribution is subject to the Boost Software License, 11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 12 // http://www.boost.org/LICENSE_1_0.txt) 13 14 #ifndef BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP 15 #define BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP 16 17 18 #include <boost/mpl/if.hpp> 19 20 21 namespace boost { namespace geometry 22 { 23 24 25 /*! 26 \brief Meta-function to define a const or non const type 27 \ingroup utility 28 \details If the boolean template parameter is true, the type parameter 29 will be defined as const, otherwise it will be defined as it was. 30 This meta-function is used to have one implementation for both 31 const and non const references 32 \note This traits class is completely independant from Boost.Geometry 33 and might be a separate addition to Boost 34 \note Used in a.o. for_each, interior_rings, exterior_ring 35 \par Example 36 \code 37 void foo(typename add_const_if_c<IsConst, Point>::type& point) 38 \endcode 39 */ 40 template <bool IsConst, typename Type> 41 struct add_const_if_c 42 { 43 typedef typename boost::mpl::if_c 44 < 45 IsConst, 46 Type const, 47 Type 48 >::type type; 49 }; 50 51 52 53 }} // namespace boost::geometry 54 55 56 #endif // BOOST_GEOMETRY_UTIL_ADD_CONST_IF_C_HPP 57