aligned_space.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. Copyright (c) 2005-2020 Intel Corporation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #include "internal/_deprecated_header_message_guard.h"
  14. #if !defined(__TBB_show_deprecation_message_aligned_space_H) && defined(__TBB_show_deprecated_header_message)
  15. #define __TBB_show_deprecation_message_aligned_space_H
  16. #pragma message("TBB Warning: tbb/aligned_space.h is deprecated. For details, please see Deprecated Features appendix in the TBB reference manual.")
  17. #endif
  18. #if defined(__TBB_show_deprecated_header_message)
  19. #undef __TBB_show_deprecated_header_message
  20. #endif
  21. #ifndef __TBB_aligned_space_H
  22. #define __TBB_aligned_space_H
  23. #define __TBB_aligned_space_H_include_area
  24. #include "internal/_warning_suppress_enable_notice.h"
  25. #include "tbb_stddef.h"
  26. #include "tbb_machine.h"
  27. namespace tbb {
  28. //! Block of space aligned sufficiently to construct an array T with N elements.
  29. /** The elements are not constructed or destroyed by this class.
  30. @ingroup memory_allocation */
  31. template<typename T,size_t N=1>
  32. class __TBB_DEPRECATED_IN_VERBOSE_MODE_MSG("tbb::aligned_space is deprecated, use std::aligned_storage") aligned_space {
  33. private:
  34. typedef __TBB_TypeWithAlignmentAtLeastAsStrict(T) element_type;
  35. element_type array[(sizeof(T)*N+sizeof(element_type)-1)/sizeof(element_type)];
  36. public:
  37. //! Pointer to beginning of array
  38. T* begin() const {return internal::punned_cast<T*>(this);}
  39. //! Pointer to one past last element in array.
  40. T* end() const {return begin()+N;}
  41. };
  42. } // namespace tbb
  43. #include "internal/_warning_suppress_disable_notice.h"
  44. #undef __TBB_aligned_space_H_include_area
  45. #endif /* __TBB_aligned_space_H */