indent classes, align by spaces

This commit is contained in:
Garux
2021-03-24 00:25:15 +03:00
parent 5b1b9b5e6c
commit 2222100316
450 changed files with 42485 additions and 42239 deletions

View File

@@ -33,13 +33,13 @@ namespace
{
class Bleh
{
int* m_blah;
int* m_blah;
public:
Bleh( int* blah ) : m_blah( blah ){
}
~Bleh(){
*m_blah = 15;
}
Bleh( int* blah ) : m_blah( blah ){
}
~Bleh(){
*m_blah = 15;
}
};
void TestAllocator(){

View File

@@ -38,50 +38,50 @@ class DefaultAllocator
{
public:
typedef Type value_type;
typedef value_type* pointer;
typedef const Type* const_pointer;
typedef Type& reference;
typedef const Type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef Type value_type;
typedef value_type* pointer;
typedef const Type* const_pointer;
typedef Type& reference;
typedef const Type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
template<typename Other>
struct rebind
{
typedef DefaultAllocator<Other> other;
};
template<typename Other>
struct rebind
{
typedef DefaultAllocator<Other> other;
};
DefaultAllocator(){
}
DefaultAllocator( const DefaultAllocator<Type>& ){
}
template<typename Other> DefaultAllocator( const DefaultAllocator<Other>& ){
}
~DefaultAllocator(){
}
DefaultAllocator(){
}
DefaultAllocator( const DefaultAllocator<Type>& ){
}
template<typename Other> DefaultAllocator( const DefaultAllocator<Other>& ){
}
~DefaultAllocator(){
}
pointer address( reference instance ) const {
return &instance;
}
const_pointer address( const_reference instance ) const {
return &instance;
}
Type* allocate( size_type size, const void* = 0 ){
return static_cast<Type*>( ::operator new( size * sizeof( Type ) ) );
}
void deallocate( pointer p, size_type ){
::operator delete( p );
}
size_type max_size() const {
return std::size_t( -1 ) / sizeof( Type );
}
void construct( pointer p, const Type& value ){
new(p) Type( value );
}
void destroy( pointer p ){
p->~Type();
}
pointer address( reference instance ) const {
return &instance;
}
const_pointer address( const_reference instance ) const {
return &instance;
}
Type* allocate( size_type size, const void* = 0 ){
return static_cast<Type*>( ::operator new( size * sizeof( Type ) ) );
}
void deallocate( pointer p, size_type ){
::operator delete( p );
}
size_type max_size() const {
return std::size_t( -1 ) / sizeof( Type );
}
void construct( pointer p, const Type& value ){
new(p) Type( value );
}
void destroy( pointer p ){
p->~Type();
}
};
template<typename Type, typename Other>
@@ -99,66 +99,66 @@ inline bool operator==( const DefaultAllocator<Type>&, const OtherAllocator& ){
template<typename Type>
class NamedAllocator : public DefaultAllocator<Type>
{
typedef DefaultAllocator<Type> allocator_type;
typedef DefaultAllocator<Type> allocator_type;
const char* m_name;
const char* m_name;
public:
typedef Type value_type;
typedef value_type* pointer;
typedef const Type* const_pointer;
typedef Type& reference;
typedef const Type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef Type value_type;
typedef value_type* pointer;
typedef const Type* const_pointer;
typedef Type& reference;
typedef const Type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
template<typename Other>
struct rebind
{
typedef NamedAllocator<Other> other;
};
template<typename Other>
struct rebind
{
typedef NamedAllocator<Other> other;
};
explicit NamedAllocator( const char* name ) : m_name( name ){
}
NamedAllocator( const NamedAllocator<Type>& other ) : m_name( other.m_name ){
}
template<typename Other> NamedAllocator( const NamedAllocator<Other>& other ) : m_name( other.m_name ){
}
~NamedAllocator(){
}
explicit NamedAllocator( const char* name ) : m_name( name ){
}
NamedAllocator( const NamedAllocator<Type>& other ) : m_name( other.m_name ){
}
template<typename Other> NamedAllocator( const NamedAllocator<Other>& other ) : m_name( other.m_name ){
}
~NamedAllocator(){
}
pointer address( reference instance ) const {
return allocator_type::address( instance );
}
const_pointer address( const_reference instance ) const {
return allocator_type::address( instance );
}
Type* allocate( size_type size, const void* = 0 ){
return allocator_type::allocate( size );
}
void deallocate( pointer p, size_type size ){
allocator_type::deallocate( p, size );
}
size_type max_size() const {
return allocator_type::max_size();
}
void construct( pointer p, const Type& value ){
allocator_type::construct( p, value );
}
void destroy( pointer p ){
allocator_type::destroy( p );
}
pointer address( reference instance ) const {
return allocator_type::address( instance );
}
const_pointer address( const_reference instance ) const {
return allocator_type::address( instance );
}
Type* allocate( size_type size, const void* = 0 ){
return allocator_type::allocate( size );
}
void deallocate( pointer p, size_type size ){
allocator_type::deallocate( p, size );
}
size_type max_size() const {
return allocator_type::max_size();
}
void construct( pointer p, const Type& value ){
allocator_type::construct( p, value );
}
void destroy( pointer p ){
allocator_type::destroy( p );
}
template<typename Other>
bool operator==( const NamedAllocator<Other>& other ){
return true;
}
template<typename Other>
bool operator==( const NamedAllocator<Other>& other ){
return true;
}
// returns true if the allocators are not interchangeable
template<typename Other>
bool operator!=( const NamedAllocator<Other>& other ){
return false;
}
template<typename Other>
bool operator!=( const NamedAllocator<Other>& other ){
return false;
}
};
@@ -172,105 +172,105 @@ template<typename Type>
class DefaultConstruct
{
public:
void operator()( Type& t ){
constructor( t );
}
void operator()( Type& t ){
constructor( t );
}
};
template<typename Type, typename T1>
class Construct
{
const T1& other;
const T1& other;
public:
Construct( const T1& other_ ) : other( other_ ){
}
void operator()( Type& t ){
constructor( t, other );
}
Construct( const T1& other_ ) : other( other_ ){
}
void operator()( Type& t ){
constructor( t, other );
}
};
template<typename Type>
class Destroy
{
public:
void operator()( Type& t ){
destructor( t );
}
void operator()( Type& t ){
destructor( t );
}
};
template<typename Type, typename Allocator = DefaultAllocator<Type> >
class New : public Allocator
{
public:
New(){
}
explicit New( const Allocator& allocator ) : Allocator( allocator ){
}
New(){
}
explicit New( const Allocator& allocator ) : Allocator( allocator ){
}
Type* scalar(){
return new( Allocator::allocate( 1 ) )Type();
}
template<typename T1>
Type* scalar( const T1& t1 ){
return new( Allocator::allocate( 1 ) )Type( t1 );
}
template<typename T1, typename T2>
Type* scalar( const T1& t1, const T2& t2 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2 );
}
template<typename T1, typename T2, typename T3>
Type* scalar( const T1& t1, const T2& t2, const T3& t3 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3 );
}
template<typename T1, typename T2, typename T3, typename T4>
Type* scalar( const T1& t1, const T2& t2, const T3& t3, const T4& t4 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3, t4 );
}
template<typename T1, typename T2, typename T3, typename T4, typename T5>
Type* scalar( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3, t4, t5 );
}
Type* vector( std::size_t size ){
Type* scalar(){
return new( Allocator::allocate( 1 ) )Type();
}
template<typename T1>
Type* scalar( const T1& t1 ){
return new( Allocator::allocate( 1 ) )Type( t1 );
}
template<typename T1, typename T2>
Type* scalar( const T1& t1, const T2& t2 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2 );
}
template<typename T1, typename T2, typename T3>
Type* scalar( const T1& t1, const T2& t2, const T3& t3 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3 );
}
template<typename T1, typename T2, typename T3, typename T4>
Type* scalar( const T1& t1, const T2& t2, const T3& t3, const T4& t4 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3, t4 );
}
template<typename T1, typename T2, typename T3, typename T4, typename T5>
Type* scalar( const T1& t1, const T2& t2, const T3& t3, const T4& t4, const T5& t5 ){
return new( Allocator::allocate( 1 ) )Type( t1, t2, t3, t4, t5 );
}
Type* vector( std::size_t size ){
#if 1
Type* p = Allocator::allocate( size );
std::for_each( p, p + size, DefaultConstruct<Type>() );
return p;
Type* p = Allocator::allocate( size );
std::for_each( p, p + size, DefaultConstruct<Type>() );
return p;
#else
// this does not work with msvc71 runtime
return new( Allocator::allocate( size ) )Type[size];
// this does not work with msvc71 runtime
return new( Allocator::allocate( size ) )Type[size];
#endif
}
template<typename T1>
Type* vector( std::size_t size, const T1& t1 ){
Type* p = Allocator::allocate( size );
std::for_each( p, p + size, Construct<Type, T1>( t1 ) );
return p;
}
}
template<typename T1>
Type* vector( std::size_t size, const T1& t1 ){
Type* p = Allocator::allocate( size );
std::for_each( p, p + size, Construct<Type, T1>( t1 ) );
return p;
}
};
template<typename Type, typename Allocator = DefaultAllocator<Type> >
class Delete : public Allocator
{
public:
Delete(){
}
explicit Delete( const Allocator& allocator ) : Allocator( allocator ){
}
Delete(){
}
explicit Delete( const Allocator& allocator ) : Allocator( allocator ){
}
void scalar( Type* p ){
if ( p != 0 ) {
p->~Type();
Allocator::deallocate( p, 1 );
void scalar( Type* p ){
if ( p != 0 ) {
p->~Type();
Allocator::deallocate( p, 1 );
}
}
}
void vector( Type* p, std::size_t size ){
// '::operator delete' handles null
// 'std::allocator::deallocate' requires non-null
if ( p != 0 ) {
std::for_each( p, p + size, Destroy<Type>() );
Allocator::deallocate( p, size );
void vector( Type* p, std::size_t size ){
// '::operator delete' handles null
// 'std::allocator::deallocate' requires non-null
if ( p != 0 ) {
std::for_each( p, p + size, Destroy<Type>() );
Allocator::deallocate( p, size );
}
}
}
};
@@ -278,14 +278,14 @@ template<typename Type>
class NamedNew
{
public:
typedef New<Type, NamedAllocator<Type> > type;
typedef New<Type, NamedAllocator<Type> > type;
};
template<typename Type>
class NamedDelete
{
public:
typedef Delete<Type, NamedAllocator<Type> > type;
typedef Delete<Type, NamedAllocator<Type> > type;
};
#endif