PageRenderTime 20ms CodeModel.GetById 10ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/src/contrib/boost/spirit/home/phoenix/detail/local_reference.hpp

http://pythonocc.googlecode.com/
C++ Header | 44 lines | 30 code | 8 blank | 6 comment | 0 complexity | 2bb36c3ce809e5c0b9b2f9d1b4d18f12 MD5 | raw file
 1/*=============================================================================
 2    Copyright (c) 2005-2007 Joel de Guzman
 3
 4    Distributed under the Boost Software License, Version 1.0. (See accompanying 
 5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 6==============================================================================*/
 7#ifndef PHOENIX_DETAIL_LOCAL_REFERENCE_HPP
 8#define PHOENIX_DETAIL_LOCAL_REFERENCE_HPP
 9
10#include <boost/utility/addressof.hpp>
11
12namespace boost { namespace phoenix { namespace detail
13{
14    template <typename T>
15    struct local_reference
16    { 
17        typedef T type;
18    
19        explicit local_reference(T& t): t_(boost::addressof(t)) {}
20        operator T& () const { return *t_; }
21        local_reference& operator=(T const& x) { *t_ = x; return *this; }
22        local_reference const& operator=(T const& x) const { *t_ = x; return *this; }
23        T& get() const { return *t_; }
24        T* get_pointer() const { return t_; }
25    
26    private:
27    
28        T* t_;
29    };
30    
31    template <typename T>
32    struct unwrap_local_reference
33    {
34        typedef T type; // T should be a reference
35    };
36
37    template <typename T>
38    struct unwrap_local_reference<local_reference<T> >
39    {
40        typedef T type; // unwrap the reference; T is a value
41    };
42}}}
43
44#endif