/usr/include/osl/misc/construct.h is in libosl-dev 0.6.0-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | /* construct.h
*/
#ifndef OSL_CONSTRUCT_H
#define OSL_CONSTRUCT_H
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/utility/enable_if.hpp>
#include <iterator>
#include <memory>
#include <cassert>
namespace osl
{
class Piece;
class Move;
class Square;
namespace rating
{
class RatedMove;
}
namespace misc
{
namespace detail
{
/** use raw memory copy instead of placement new not to test a given pointer is null */
template <typename T>
struct BitCopyTraits
{
static const bool value=boost::is_pod<T>::value;
};
template <> struct BitCopyTraits<Move> { static const bool value=true; };
template <> struct BitCopyTraits<Piece> { static const bool value=true; };
template <> struct BitCopyTraits<Square> { static const bool value=true; };
template <> struct BitCopyTraits<rating::RatedMove> { static const bool value=true; };
}
template <typename T1, typename T2>
inline
void construct(T1* ptr, const T2& value,
typename boost::enable_if<detail::BitCopyTraits<T1> >::type * =0)
{
assert(ptr);
*ptr = T1(value);
}
template <typename T1, typename T2>
inline
void construct(T1* ptr, const T2& value,
typename boost::disable_if<detail::BitCopyTraits<T1> >::type * =0)
{
assert(ptr);
::new(ptr) T1(value);
}
template <typename T>
inline void destroy(T *ptr)
{
ptr->~T();
}
template <typename ForwardIterator>
inline void destroy(ForwardIterator first, ForwardIterator last)
{
typedef typename std::iterator_traits<ForwardIterator>::value_type
value_type;
if (boost::has_trivial_destructor<value_type>::value)
return;
for (; first != last; ++first)
destroy(&*first);
}
}
}
#endif /* OSL_CONSTRUCT_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|