Chris@16: /*============================================================================= Chris@16: Copyright (c) 2005-2007 Joel de Guzman Chris@16: Chris@16: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@16: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: ==============================================================================*/ Chris@16: #ifndef PHOENIX_DETAIL_LOCAL_REFERENCE_HPP Chris@16: #define PHOENIX_DETAIL_LOCAL_REFERENCE_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { namespace phoenix { namespace detail Chris@16: { Chris@16: template Chris@16: struct local_reference Chris@16: { Chris@16: typedef T type; Chris@16: Chris@16: explicit local_reference(T& t): t_(boost::addressof(t)) {} Chris@16: operator T& () const { return *t_; } Chris@16: local_reference& operator=(T const& x) { *t_ = x; return *this; } Chris@16: local_reference const& operator=(T const& x) const { *t_ = x; return *this; } Chris@16: T& get() const { return *t_; } Chris@16: T* get_pointer() const { return t_; } Chris@16: Chris@16: private: Chris@16: Chris@16: T* t_; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct unwrap_local_reference Chris@16: { Chris@16: typedef T type; // T should be a reference Chris@16: }; Chris@16: Chris@16: template Chris@16: struct unwrap_local_reference > Chris@16: { Chris@16: typedef T type; // unwrap the reference; T is a value Chris@16: }; Chris@16: }}} Chris@16: Chris@16: #endif