1 // This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
2 // the main distribution directory for license terms and copyright or visit
3 // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
4 
5 #pragma once
6 
7 // This function performs a const_cast. Naturally, calling it is almost always a
8 // very bad idea. With one notable exception: writing code for type inspection.
9 
10 namespace caf::detail {
11 
12 template <class T>
as_mutable_ref(T & x)13 T& as_mutable_ref(T& x) {
14   return x;
15 }
16 
17 template <class T>
as_mutable_ref(const T & x)18 T& as_mutable_ref(const T& x) {
19   return const_cast<T&>(x);
20 }
21 
22 } // namespace caf::detail
23