add_const_if_c.hpp 1.6 KB

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