os/ossrv/ossrv_pub/boost_apis/boost/python/other.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
#ifndef OTHER_DWA20020601_HPP
sl@0
     2
# define OTHER_DWA20020601_HPP
sl@0
     3
sl@0
     4
# include <boost/python/detail/prefix.hpp>
sl@0
     5
// Copyright David Abrahams 2002.
sl@0
     6
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     7
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     8
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     9
sl@0
    10
# if _MSC_VER+0 >= 1020
sl@0
    11
#  pragma once
sl@0
    12
# endif
sl@0
    13
sl@0
    14
# include <boost/config.hpp>
sl@0
    15
sl@0
    16
namespace boost { namespace python {
sl@0
    17
sl@0
    18
template<class T> struct other
sl@0
    19
{ 
sl@0
    20
    typedef T type;
sl@0
    21
};
sl@0
    22
sl@0
    23
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
    24
namespace detail
sl@0
    25
{
sl@0
    26
  template<typename T>
sl@0
    27
  class is_other
sl@0
    28
  {
sl@0
    29
   public:
sl@0
    30
      BOOST_STATIC_CONSTANT(bool, value = false); 
sl@0
    31
  };
sl@0
    32
sl@0
    33
  template<typename T>
sl@0
    34
  class is_other<other<T> >
sl@0
    35
  {
sl@0
    36
   public:
sl@0
    37
      BOOST_STATIC_CONSTANT(bool, value = true);
sl@0
    38
  };
sl@0
    39
sl@0
    40
  template<typename T>
sl@0
    41
  class unwrap_other
sl@0
    42
  {
sl@0
    43
   public:
sl@0
    44
      typedef T type;
sl@0
    45
  };
sl@0
    46
sl@0
    47
  template<typename T>
sl@0
    48
  class unwrap_other<other<T> >
sl@0
    49
  {
sl@0
    50
   public:
sl@0
    51
      typedef T type;
sl@0
    52
  };
sl@0
    53
}
sl@0
    54
# else // no partial specialization
sl@0
    55
sl@0
    56
}} // namespace boost::python
sl@0
    57
sl@0
    58
#include <boost/type.hpp>
sl@0
    59
sl@0
    60
namespace boost { namespace python {
sl@0
    61
sl@0
    62
namespace detail
sl@0
    63
{
sl@0
    64
  typedef char (&yes_other_t)[1];
sl@0
    65
  typedef char (&no_other_t)[2];
sl@0
    66
      
sl@0
    67
  no_other_t is_other_test(...);
sl@0
    68
sl@0
    69
  template<typename T>
sl@0
    70
  yes_other_t is_other_test(type< other<T> >);
sl@0
    71
sl@0
    72
  template<bool wrapped>
sl@0
    73
  struct other_unwrapper
sl@0
    74
  {
sl@0
    75
      template <class T>
sl@0
    76
      struct apply
sl@0
    77
      {
sl@0
    78
          typedef T type;
sl@0
    79
      };
sl@0
    80
  };
sl@0
    81
sl@0
    82
  template<>
sl@0
    83
  struct other_unwrapper<true>
sl@0
    84
  {
sl@0
    85
      template <class T>
sl@0
    86
      struct apply
sl@0
    87
      {
sl@0
    88
          typedef typename T::type type;
sl@0
    89
      };
sl@0
    90
  };
sl@0
    91
sl@0
    92
  template<typename T>
sl@0
    93
  class is_other
sl@0
    94
  {
sl@0
    95
   public:
sl@0
    96
      BOOST_STATIC_CONSTANT(
sl@0
    97
          bool, value = (
sl@0
    98
              sizeof(detail::is_other_test(type<T>()))
sl@0
    99
              == sizeof(detail::yes_other_t)));
sl@0
   100
  };
sl@0
   101
sl@0
   102
  template <typename T>
sl@0
   103
  class unwrap_other
sl@0
   104
      : public detail::other_unwrapper<
sl@0
   105
      is_other<T>::value
sl@0
   106
  >::template apply<T>
sl@0
   107
  {};
sl@0
   108
}
sl@0
   109
sl@0
   110
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
sl@0
   111
sl@0
   112
}} // namespace boost::python
sl@0
   113
sl@0
   114
#endif // #ifndef OTHER_DWA20020601_HPP