/*============================================================================= Copyright (c) 2005-2012 Joel de Guzman Copyright (c) 2005-2006 Dan Marsden Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #if !defined(BOOST_FUSION_DEQUE_DETAIL_KEYED_ELEMENT_26112006_1330) #define BOOST_FUSION_DEQUE_DETAIL_KEYED_ELEMENT_26112006_1330 #include #include #include #include namespace boost { namespace fusion { struct fusion_sequence_tag; }} namespace boost { namespace fusion { namespace detail { struct nil_keyed_element { typedef fusion_sequence_tag tag; BOOST_FUSION_GPU_ENABLED void get(); template BOOST_FUSION_GPU_ENABLED static nil_keyed_element from_iterator(It const&) { return nil_keyed_element(); } }; template struct keyed_element : Rest { typedef Rest base; typedef fusion_sequence_tag tag; using Rest::get; template BOOST_FUSION_GPU_ENABLED static keyed_element from_iterator(It const& it) { return keyed_element( *it, base::from_iterator(fusion::next(it))); } BOOST_FUSION_GPU_ENABLED keyed_element(keyed_element const& rhs) : Rest(rhs.get_base()), value_(rhs.value_) {} #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_FUSION_GPU_ENABLED keyed_element(keyed_element&& rhs) : Rest(std::forward(rhs.forward_base())) , value_(std::forward(rhs.value_)) {} #endif template BOOST_FUSION_GPU_ENABLED keyed_element(keyed_element const& rhs) : Rest(rhs.get_base()), value_(rhs.value_) {} #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) #endif BOOST_FUSION_GPU_ENABLED Rest& get_base() { return *this; } BOOST_FUSION_GPU_ENABLED Rest const& get_base() const { return *this; } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_FUSION_GPU_ENABLED Rest&& forward_base() { return std::forward(*static_cast(this)); } #endif BOOST_FUSION_GPU_ENABLED typename cref_result::type get(Key) const { return value_; } BOOST_FUSION_GPU_ENABLED typename ref_result::type get(Key) { return value_; } BOOST_FUSION_GPU_ENABLED keyed_element( typename detail::call_param::type value , Rest const& rest) : Rest(rest), value_(value) {} #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_FUSION_GPU_ENABLED keyed_element(Value&& value, Rest&& rest) : Rest(std::forward(rest)) , value_(std::forward(value)) {} #endif BOOST_FUSION_GPU_ENABLED keyed_element() : Rest(), value_() {} template BOOST_FUSION_GPU_ENABLED keyed_element& operator=(keyed_element const& rhs) { base::operator=(static_cast(rhs)); // cast for msvc-7.1 value_ = rhs.value_; return *this; } BOOST_FUSION_GPU_ENABLED keyed_element& operator=(keyed_element const& rhs) { base::operator=(rhs); value_ = rhs.value_; return *this; } #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) BOOST_FUSION_GPU_ENABLED keyed_element& operator=(keyed_element&& rhs) { base::operator=(std::forward(rhs)); value_ = std::forward(rhs.value_); return *this; } #endif Value value_; }; template struct keyed_element_value_at : keyed_element_value_at {}; template struct keyed_element_value_at, Key> { typedef Value type; }; }}} #endif