Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / String_Traits_T.h
blob3140ce3edcaac882e10375611d946a768fc3dbf4
1 #ifndef guard_string_traits_hpp
2 #define guard_string_traits_hpp
3 /**
4 * @file
6 * @brief Implement the element manipulation traits for string types.
8 * @author Carlos O'Ryan
9 */
11 #include "String_Traits_Base_T.h"
12 #include "ace/OS_NS_string.h"
14 #include <algorithm>
15 #include <functional>
17 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 namespace TAO
21 namespace details
23 template<typename char_type, class derived>
24 struct string_traits_decorator
26 typedef char_type * value_type;
27 typedef char_type const * const_value_type;
29 inline static void zero_range(
30 char_type ** begin, char_type ** end)
32 ACE_OS::memset (begin, 0, (end - begin) * sizeof (char_type*));
35 inline static void initialize_range(
36 char_type ** begin, char_type ** end)
38 std::generate(begin, end, &derived::default_initializer);
41 // Allow MSVC++ >= 8 checked iterators to be used.
42 template <typename iter>
43 inline static void copy_range(
44 char_type ** begin, char_type ** end, iter dst)
46 std::transform(begin, end, dst, &derived::duplicate);
49 // Allow MSVC++ >= 8 checked iterators to be used.
50 template <typename iter>
51 inline static void copy_swap_range(
52 char_type ** begin, char_type ** end, iter dst)
54 std::swap_ranges(begin, end, dst);
57 inline static void release_range(
58 char_type ** begin, char_type ** end)
60 std::for_each(begin, end, &derived::release);
63 inline static char_type const * initialize_if_zero(char_type * & element)
65 if (element == 0)
67 element = derived::default_initializer();
69 return element;
73 template<class charT, bool dummy>
74 struct string_traits
75 : public string_traits_base<charT>
76 , public string_traits_decorator<charT,string_traits<charT,dummy> >
79 } // namespace details
80 } // namespace CORBA
82 TAO_END_VERSIONED_NAMESPACE_DECL
84 #endif // guard_string_traits_hpp