Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
spatial_mutate.hpp
1 // -*- C++ -*-
2 //
3 // Copyright Sylvain Bougerel 2009 - 2013.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file COPYING or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
13 #ifndef SPATIAL_MUTATE_HPP
14 #define SPATIAL_MUTATE_HPP
15 
16 namespace spatial
17 {
18  namespace details
19  {
21 
24  template<typename Tp>
25  struct mutate { typedef Tp type; };
26  template <typename Tp>
27  struct mutate<const Tp> { typedef Tp type; };
29 
31 
35  template<typename Tp>
36  inline Tp*
37  mutate_pointer(const Tp* p) { return const_cast<Tp*>(p); }
38 
39  template<typename Tp>
40  inline Tp*
41  mutate_pointer(Tp* p) { return p; } // hoping this one gets optimized away
43  }
44 }
45 
46 #endif // SPATIAL_MUTATE_HPP
Changes a const type into a mutable type.
Tp * mutate_pointer(const Tp *p)
A helper functions that mutates pointers.
The main namespace used in the library.
Definition: algorithm.hpp:23