Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Array_Traits_T.h
blobba30cd908567bc6b940f1a36a9ac3824ac263497
1 #ifndef guard_array_traits_hpp
2 #define guard_array_traits_hpp
3 /**
4 * @file
6 * @brief Implement the element manipulation traits for types with
7 * array-like semantics.
9 * @author Carlos O'Ryan
12 #include <algorithm>
13 #include "tao/Array_VarOut_T.h"
15 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
17 namespace TAO
19 namespace details
21 template <typename T_forany>
22 struct array_traits
24 typedef T_forany forany_type;
25 typedef typename T_forany::_array_type value_type;
26 typedef typename T_forany::_array_type const const_value_type;
27 typedef typename T_forany::_slice_type slice_type;
29 inline static void copy (slice_type * _tao_to, const slice_type * _tao_from)
31 TAO::Array_Traits<forany_type>::copy (_tao_to, _tao_from);
34 inline static void free (slice_type * value)
36 TAO::Array_Traits<forany_type>::free (value);
39 inline static slice_type * alloc ()
41 return TAO::Array_Traits<forany_type>::alloc ();
44 inline static slice_type * dup(
45 const slice_type * value)
47 return TAO::Array_Traits<forany_type>::dup (value);
50 inline static void zero_range(
51 value_type * begin, value_type * end)
53 std::for_each(
54 begin, end, &TAO::Array_Traits<forany_type>::zero);
57 inline static void release_range(
58 value_type *, value_type *)
60 // Noop for array sequences
63 inline static void initialize_range(
64 value_type * begin, value_type * end)
66 std::for_each(
67 begin, end, &TAO::Array_Traits<forany_type>::zero);
70 // Allow MSVC++ >= 8 checked iterators to be used.
71 template <typename iter>
72 inline static void copy_range(
73 value_type * begin, value_type * end, iter dst)
75 for(value_type * i = begin; i != end; ++i, ++dst)
77 TAO::Array_Traits<forany_type>::copy(*dst, *i);
81 // Allow MSVC++ >= 8 checked iterators to be used.
82 template <typename iter>
83 inline static void copy_swap_range(
84 value_type * begin, value_type * end, iter dst)
86 copy_range(begin, end, dst);
89 } // namespace details
90 } // namespace CORBA
92 TAO_END_VERSIONED_NAMESPACE_DECL
94 #endif // guard_array_traits_hpp