Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / Bounded_Reference_Allocation_Traits_T.h
blob4306e009ee19c0048aaccd787f51b9fb2a9e324e
1 #ifndef guard_bounded_reference_allocation_traits_hpp
2 #define guard_bounded_reference_allocation_traits_hpp
3 /**
4 * @file
6 * @brief Details can be found in the documentation for
7 * TAO::details::generic_sequence
9 * @author Carlos O'Ryan
12 #include "tao/Basic_Types.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 namespace TAO
18 namespace details
20 template<typename T, class ref_traits, CORBA::ULong MAX, bool dummy>
21 struct bounded_reference_allocation_traits
23 typedef T value_type;
24 typedef ref_traits reference_traits;
26 inline static CORBA::ULong default_maximum()
28 return MAX;
31 inline static value_type * default_buffer_allocation()
33 return 0;
36 inline static value_type * allocbuf(CORBA::ULong /* maximum */)
38 value_type * buffer = new value_type[MAX];
39 // no throw
40 reference_traits::initialize_range(buffer, buffer + MAX);
42 return buffer;
45 inline static value_type * allocbuf_noinit(CORBA::ULong /* maximum */)
47 value_type * buffer = new value_type[MAX];
48 // no throw
49 reference_traits::zero_range(buffer, buffer + MAX);
51 return buffer;
54 inline static void freebuf(value_type * buffer)
56 reference_traits::release_range(buffer, buffer + MAX);
57 delete[] buffer;
60 inline static CORBA::ULong maximum()
62 return MAX;
65 } // namespace details
66 } // namespace TAO
68 TAO_END_VERSIONED_NAMESPACE_DECL
70 #endif // guard_bounded_reference_allocation_traits_hpp