construct.h 500 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __DAHUA_INFRA_CONSTRUCT_H__
  2. #define __DAHUA_INFRA_CONSTRUCT_H__
  3. namespace Dahua {
  4. namespace Infra {
  5. namespace Datail {
  6. template <typename T>
  7. void construct(T* addr, T const& value)
  8. {
  9. new (addr) T(value);
  10. }
  11. template <typename T>
  12. void destruct(T& value)
  13. {
  14. value.~T();
  15. }
  16. #if !defined(_MSC_VER) || (_MSC_VER > 1300)
  17. template <typename T>
  18. void destruct(T* value)
  19. {
  20. value->~T();
  21. }
  22. #endif
  23. } // end of Detail
  24. } // end of Infra
  25. } // end of Dahua
  26. #endif // end of __DAHUA_INFRA_CONSTRUCT_H__