-//$$CDS-header$$
+/*
+ This file is a part of libcds - Concurrent Data Structures library
-#ifndef __CDS_DETAILS_ALIGNED_ALLOCATOR_H
-#define __CDS_DETAILS_ALIGNED_ALLOCATOR_H
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+ Source code repo: http://github.com/khizmax/libcds/
+ Download: http://sourceforge.net/projects/libcds/files/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef CDSLIB_DETAILS_ALIGNED_ALLOCATOR_H
+#define CDSLIB_DETAILS_ALIGNED_ALLOCATOR_H
#include <cds/details/defs.h>
#include <cds/user_setup/allocator.h>
/// Underlying aligned allocator type
typedef typename ALIGNED_ALLOCATOR::template rebind<T>::other allocator_type;
-# ifdef CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT
/// Analogue of operator new T(\p src... )
template <typename... S>
T * New( size_t nAlign, const S&... src )
{
return Construct( allocator_type::allocate( nAlign, 1), src... );
}
-# else
- //@cond
- /// Analogue of operator new T
- T * New( size_t nAlign )
- {
- return Construct( allocator_type::allocate(nAlign, 1) );
- }
-
- /// Analogue of operator new T(\p src )
- template <typename S>
- T * New( size_t nAlign, const S& src )
- {
- return Construct( allocator_type::allocate( nAlign, 1), src );
- }
-
- /// Analogue of operator new T( \p s1, \p s2 )
- template <typename S1, typename S2>
- T * New( size_t nAlign, const S1& s1, const S2& s2 )
- {
- return Construct( allocator_type::allocate( nAlign, 1 ), s1, s2 );
- }
-
- /// Analogue of operator new T( \p s1, \p s2, \p s3 )
- template <typename S1, typename S2, typename S3>
- T * New( size_t nAlign, const S1& s1, const S2& s2, const S3& s3 )
- {
- return Construct( allocator_type::allocate(nAlign, 1), s1, s2, s3 );
- }
- //@endcond
-# endif
/// Analogue of operator new T[\p nCount ]
T * NewArray( size_t nAlign, size_t nCount )
allocator_type::deallocate( p, nCount );
}
-# ifdef CDS_CXX11_VARIADIC_TEMPLATE_SUPPORT
/// Analogue of placement operator new( \p p ) T( \p src... )
template <typename... S>
T * Construct( void * p, const S&... src )
{
return new( p ) T( src... );
}
-# else
- /// Analogue of placement operator new( \p p ) T
- T * Construct( void * p )
- {
- return new( p ) T;
- }
-
- /// Analogue of placement operator new( \p p ) T( \p src )
- template <typename S>
- T * Construct( void * p, const S& src )
- {
- return new( p ) T( src );
- }
-
- /// Analogue of placement operator new( \p p ) T( \p s1, \p s2 )
- template <typename S1, typename S2>
- T * Construct( void * p, const S1& s1, const S2& s2 )
- {
- return new( p ) T( s1, s2 );
- }
-
- /// Analogue of placement operator new( \p p ) T( \p s1, \p s2, \p s3 )
- template <typename S1, typename S2, typename S3>
- T * Construct( void * p, const S1& s1, const S2& s2, const S3& s3 )
- {
- return new( p ) T( s1, s2, s3 );
- }
-# endif
/// Rebinds allocator to other type \p Q instead of \p T
template <typename Q>
}} // namespace cds::details
-#endif // #ifndef __CDS_DETAILS_ALIGNED_ALLOCATOR_H
+#endif // #ifndef CDSLIB_DETAILS_ALIGNED_ALLOCATOR_H