tuple.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef TUPLE_20020706_HPP
  6. #define TUPLE_20020706_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. #include <boost/python/object.hpp>
  9. #include <boost/python/converter/pytype_object_mgr_traits.hpp>
  10. #include <boost/preprocessor/enum_params.hpp>
  11. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  12. namespace boost { namespace python {
  13. namespace detail
  14. {
  15. struct BOOST_PYTHON_DECL tuple_base : object
  16. {
  17. protected:
  18. tuple_base();
  19. tuple_base(object_cref sequence);
  20. BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(tuple_base, object)
  21. private:
  22. static detail::new_reference call(object const&);
  23. };
  24. }
  25. class tuple : public detail::tuple_base
  26. {
  27. typedef detail::tuple_base base;
  28. public:
  29. tuple() {}
  30. template <class T>
  31. explicit tuple(T const& sequence)
  32. : base(object(sequence))
  33. {
  34. }
  35. public: // implementation detail -- for internal use only
  36. BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(tuple, base)
  37. };
  38. //
  39. // Converter Specializations // $$$ JDG $$$ moved here to prevent
  40. // // G++ bug complaining specialization
  41. // provided after instantiation
  42. namespace converter
  43. {
  44. template <>
  45. struct object_manager_traits<tuple>
  46. : pytype_object_manager_traits<&PyTuple_Type,tuple>
  47. {
  48. };
  49. }
  50. // for completeness
  51. inline tuple make_tuple() { return tuple(); }
  52. # define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/make_tuple.hpp>))
  53. # include BOOST_PP_ITERATE()
  54. }} // namespace boost::python
  55. #endif