sl@0: // Copyright David Abrahams 2002. sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef OBJECT_ITEMS_DWA2002615_HPP sl@0: # define OBJECT_ITEMS_DWA2002615_HPP sl@0: sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { namespace python { namespace api { sl@0: sl@0: struct const_item_policies sl@0: { sl@0: typedef object key_type; sl@0: static object get(object const& target, object const& key); sl@0: }; sl@0: sl@0: struct item_policies : const_item_policies sl@0: { sl@0: static object const& set(object const& target, object const& key, object const& value); sl@0: static void del(object const& target, object const& key); sl@0: }; sl@0: sl@0: // sl@0: // implementation sl@0: // sl@0: template sl@0: inline object_item sl@0: object_operators::operator[](object_cref key) sl@0: { sl@0: object_cref2 x = *static_cast(this); sl@0: return object_item(x, key); sl@0: } sl@0: sl@0: template sl@0: inline const_object_item sl@0: object_operators::operator[](object_cref key) const sl@0: { sl@0: object_cref2 x = *static_cast(this); sl@0: return const_object_item(x, key); sl@0: } sl@0: sl@0: # if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 sl@0: template sl@0: template sl@0: inline const_object_item sl@0: object_operators::operator[](T const& key) const sl@0: { sl@0: return (*this)[object(key)]; sl@0: } sl@0: sl@0: template sl@0: template sl@0: inline object_item sl@0: object_operators::operator[](T const& key) sl@0: { sl@0: return (*this)[object(key)]; sl@0: } sl@0: # endif sl@0: sl@0: sl@0: inline object const_item_policies::get(object const& target, object const& key) sl@0: { sl@0: return getitem(target, key); sl@0: } sl@0: sl@0: inline object const& item_policies::set( sl@0: object const& target sl@0: , object const& key sl@0: , object const& value) sl@0: { sl@0: setitem(target, key, value); sl@0: return value; sl@0: } sl@0: sl@0: inline void item_policies::del( sl@0: object const& target sl@0: , object const& key) sl@0: { sl@0: delitem(target, key); sl@0: } sl@0: sl@0: }}} // namespace boost::python::api sl@0: sl@0: #endif // OBJECT_ITEMS_DWA2002615_HPP