summaryrefslogtreecommitdiff
path: root/ACE/TAO/tao/Array_Traits_T.h
blob: 1d3b98edb1e98e946e47b28bcdf13e17bedcce84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef guard_array_traits_hpp
#define guard_array_traits_hpp
/**
 * @file
 *
 * @brief Implement the element manipulation traits for types with
 * array-like semantics.
 *
 * $Id$
 *
 * @author Carlos O'Ryan
 */

#include <algorithm>
#include "tao/Array_VarOut_T.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
namespace details
{

template <typename T_forany>
struct array_traits
{
  typedef T_forany forany_type;
  typedef typename T_forany::_array_type value_type;
  typedef typename T_forany::_array_type const const_value_type;
  typedef typename T_forany::_slice_type slice_type;

  inline static void copy (slice_type * _tao_to, const slice_type * _tao_from)
  {
    TAO::Array_Traits<forany_type>::copy (_tao_to, _tao_from);
  }

  inline static void free (slice_type * value)
  {
    TAO::Array_Traits<forany_type>::free (value);
  }

  inline static slice_type * alloc (void)
  {
    return TAO::Array_Traits<forany_type>::alloc ();
  }

  inline static slice_type * dup(
      const slice_type * value)
  {
    return TAO::Array_Traits<forany_type>::dup (value);
  }

  inline static void zero_range(
      value_type * begin, value_type * end)
  {
    std::for_each(
        begin, end, &TAO::Array_Traits<forany_type>::zero);
  }

  inline static void release_range(
      value_type *, value_type *)
  {
    // Noop for array sequences
  }

  inline static void initialize_range(
      value_type * begin, value_type * end)
  {
    std::for_each(
        begin, end, &TAO::Array_Traits<forany_type>::zero);
  }

# ifndef ACE_LACKS_MEMBER_TEMPLATES
  // Allow MSVC++ >= 8 checked iterators to be used.
  template <typename iter>
  inline static void copy_range(
      value_type * begin, value_type * end, iter dst)
  {
    for(value_type * i = begin; i != end; ++i, ++dst)
    {
      TAO::Array_Traits<forany_type>::copy(*dst, *i);
    }
  }
#else
  inline static void copy_range(
      value_type * begin, value_type * end, value_type *dst)
  {
    for(value_type * i = begin; i != end; ++i, ++dst)
    {
      TAO::Array_Traits<forany_type>::copy(*dst, *i);
    }
  }
# endif  /* !ACE_LACKS_MEMBER_TEMPLATES */

#ifndef ACE_LACKS_MEMBER_TEMPLATES
  // Allow MSVC++ >= 8 checked iterators to be used.
  template <typename iter>
  inline static void copy_swap_range(
      value_type * begin, value_type * end, iter dst)
  {
    copy_range(begin, end, dst);
  }
#else
  inline static void copy_swap_range(
      value_type * begin, value_type * end, value_type *dst)
  {
    copy_range(begin, end, dst);
  }
#endif  /* !ACE_LACKS_MEMBER_TEMPLATES */
};

} // namespace details
} // namespace CORBA

TAO_END_VERSIONED_NAMESPACE_DECL

#endif // guard_array_traits_hpp