first commit
This commit is contained in:
611
extern/stdcxx/4.2.1/include/tr1/_smartptr.h
vendored
Normal file
611
extern/stdcxx/4.2.1/include/tr1/_smartptr.h
vendored
Normal file
@@ -0,0 +1,611 @@
|
||||
// -*- C++ -*-
|
||||
/***************************************************************************
|
||||
*
|
||||
* _smartptr.h - definition of class template shared_ptr and weak_ptr
|
||||
*
|
||||
* $Id: _smartptr.h 590052 2007-10-30 12:44:14Z faridz $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 2005-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _RWSTD_TR1_SMARTPTR_INCLUDED
|
||||
#define _RWSTD_TR1_SMARTPTR_INCLUDED
|
||||
|
||||
|
||||
#include <rw/_autoptr.h>
|
||||
#include <rw/_exception.h>
|
||||
#include <rw/_mutex.h>
|
||||
#include <rw/_defs.h>
|
||||
|
||||
|
||||
_RWSTD_NAMESPACE (__rw) {
|
||||
|
||||
|
||||
struct __rw_ptr_base
|
||||
{
|
||||
__rw_ptr_base ()
|
||||
: _C_ref (1), _C_weak_ref (0) { }
|
||||
|
||||
virtual ~__rw_ptr_base () {
|
||||
#ifdef _RWSTDDEBUG
|
||||
_C_ref = 0xdeadbeefL;
|
||||
_C_weak_ref = 0xdeadbeefL;
|
||||
#endif // _RWSTDDEBUG
|
||||
}
|
||||
|
||||
virtual void* _C_get_deleter () const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _C_get_ref () {
|
||||
_RWSTD_ATOMIC_PREINCREMENT (_C_ref, false);
|
||||
return _RWSTD_ATOMIC_PREDECREMENT (_C_ref, false);
|
||||
}
|
||||
|
||||
void _C_inc_ref () {
|
||||
_RWSTD_ATOMIC_PREINCREMENT (_C_ref, false);
|
||||
}
|
||||
|
||||
void _C_inc_ref_weak () {
|
||||
_RWSTD_ATOMIC_PREINCREMENT (_C_weak_ref, false);
|
||||
}
|
||||
|
||||
void _C_unref () {
|
||||
const long __ref = _RWSTD_ATOMIC_PREDECREMENT (_C_ref, false);
|
||||
if (0 == __ref)
|
||||
_C_delete ();
|
||||
|
||||
if (__ref <= 0) {
|
||||
if (0 > _RWSTD_ATOMIC_PREDECREMENT (_C_weak_ref, false))
|
||||
delete this;
|
||||
else
|
||||
_RWSTD_ATOMIC_PREINCREMENT (_C_weak_ref, false);
|
||||
}
|
||||
}
|
||||
|
||||
void _C_unref_weak () {
|
||||
if (0 >= _RWSTD_ATOMIC_PREDECREMENT (_C_weak_ref, false)) {
|
||||
if (0 > _RWSTD_ATOMIC_PREDECREMENT (_C_ref, false))
|
||||
delete this;
|
||||
else
|
||||
_RWSTD_ATOMIC_PREINCREMENT (_C_ref, false);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
virtual void _C_delete () = 0;
|
||||
|
||||
long _C_ref;
|
||||
long _C_weak_ref;
|
||||
};
|
||||
|
||||
|
||||
template <class _TypeU>
|
||||
struct __rw_ptr_body: __rw_ptr_base
|
||||
{
|
||||
__rw_ptr_body (_TypeU *__ptr)
|
||||
: __rw_ptr_base (), _C_ptr (__ptr) { }
|
||||
|
||||
protected:
|
||||
|
||||
_TypeU* const _C_ptr;
|
||||
|
||||
private:
|
||||
|
||||
virtual void _C_delete () {
|
||||
delete _C_ptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <class _TypeU, class _Deleter>
|
||||
struct __rw_ptr_deleter: __rw_ptr_body<_TypeU>
|
||||
{
|
||||
__rw_ptr_deleter (_TypeU *__ptr, const _Deleter &__del)
|
||||
: __rw_ptr_body<_TypeU>(__ptr), _C_del (__del) { }
|
||||
|
||||
private:
|
||||
|
||||
virtual void _C_delete () {
|
||||
_C_del (this->_C_ptr);
|
||||
}
|
||||
|
||||
virtual void* _C_get_deleter () const {
|
||||
return _RWSTD_CONST_CAST (_Deleter*, &_C_del);
|
||||
}
|
||||
|
||||
_Deleter _C_del;
|
||||
};
|
||||
|
||||
|
||||
} // namespace __rw
|
||||
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
_RWSTD_NAMESPACE (tr1) {
|
||||
|
||||
|
||||
// 2.2.2 - class bad_weak_ptr
|
||||
struct bad_weak_ptr: _RW::__rw_exception
|
||||
{
|
||||
bad_weak_ptr (): _RW::__rw_exception () { }
|
||||
};
|
||||
|
||||
|
||||
template <class _TypeT>
|
||||
class weak_ptr;
|
||||
|
||||
|
||||
// 2.2.3 - class template shared_ptr
|
||||
template <class _TypeT>
|
||||
class shared_ptr
|
||||
{
|
||||
// declare every specialization a friend and grant
|
||||
// template members access to _C_ptr
|
||||
template <class _TypeU>
|
||||
friend class shared_ptr;
|
||||
|
||||
template <class _TypeU>
|
||||
friend class weak_ptr;
|
||||
|
||||
template <class _TypeU, class _TypeV>
|
||||
friend shared_ptr<_TypeU>
|
||||
dynamic_pointer_cast (const shared_ptr<_TypeV>&);
|
||||
|
||||
typedef _RW::__rw_ptr_base _C_base;
|
||||
|
||||
_C_base *_C_pbody;
|
||||
_TypeT *_C_ptr;
|
||||
|
||||
template <class _TypeU>
|
||||
_EXPLICIT
|
||||
shared_ptr (const shared_ptr<_TypeU> &__rhs, const _TypeT*)
|
||||
: _C_pbody (__rhs._C_pbody) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref ();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
typedef _TypeT element_type;
|
||||
|
||||
// [2.2.3.1] constructors
|
||||
|
||||
shared_ptr (): _C_pbody (0), _C_ptr (0) { }
|
||||
|
||||
template <class _TypeU>
|
||||
_EXPLICIT
|
||||
shared_ptr (_TypeU *__ptr)
|
||||
: _C_pbody (__ptr ? new _RW::__rw_ptr_body<_TypeU>(__ptr) : 0),
|
||||
_C_ptr (__ptr) { /* empty */ }
|
||||
|
||||
template <class _TypeU, class _Deleter>
|
||||
shared_ptr (_TypeU *__ptr, _Deleter __del)
|
||||
: _C_pbody (new _RW::__rw_ptr_deleter<_TypeU, _Deleter>(__ptr, __del)),
|
||||
_C_ptr (__ptr) { /* empty */ }
|
||||
|
||||
shared_ptr (const shared_ptr &__rhs)
|
||||
: _C_pbody (__rhs._C_pbody), _C_ptr (__rhs._C_ptr) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref ();
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
shared_ptr (const shared_ptr<_TypeU> &__rhs)
|
||||
: _C_pbody (__rhs._C_pbody), _C_ptr (__rhs._C_ptr) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref ();
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
_EXPLICIT
|
||||
shared_ptr (const weak_ptr<_TypeU> &__rhs)
|
||||
: _C_pbody (__rhs._C_pbody), _C_ptr (__rhs._C_ptr) {
|
||||
if (_C_pbody) {
|
||||
if (0 >= _C_pbody->_C_get_ref ())
|
||||
throw bad_weak_ptr ();
|
||||
_C_pbody->_C_inc_ref ();
|
||||
}
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
_EXPLICIT
|
||||
shared_ptr (auto_ptr<_TypeU>&);
|
||||
|
||||
// [2.2.3.2] destructor
|
||||
~shared_ptr () {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref ();
|
||||
|
||||
#ifdef _RWSTDDEBUG
|
||||
_C_pbody = (_C_base*)0xdeadbeefL;
|
||||
_C_ptr = (element_type*)0xdeadbeefL;
|
||||
#endif // _RWSTDDEBUG
|
||||
}
|
||||
|
||||
// [2.2.3.3] assignment
|
||||
|
||||
shared_ptr& operator= (const shared_ptr &__rhs) {
|
||||
if (__rhs._C_pbody)
|
||||
__rhs._C_pbody->_C_inc_ref ();
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref ();
|
||||
_C_pbody = __rhs._C_pbody;
|
||||
_C_ptr = __rhs._C_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
shared_ptr& operator= (const shared_ptr<_TypeU> &__rhs) {
|
||||
_C_is_convertible ((_TypeU*)0);
|
||||
if (__rhs._C_pbody)
|
||||
__rhs._C_pbody->_C_inc_ref ();
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref ();
|
||||
_C_pbody = __rhs._C_pbody;
|
||||
_C_ptr = __rhs._C_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
shared_ptr& operator= (auto_ptr<_TypeU> &__rhs) {
|
||||
_RW::__rw_ptr_body<_TypeU>* const __tmp =
|
||||
new _RW::__rw_ptr_body<_TypeU>(__rhs.get ());
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref ();
|
||||
_C_pbody = __tmp;
|
||||
_C_ptr = __rhs.release ();
|
||||
return *this;
|
||||
}
|
||||
|
||||
// [2.2.3.4] modifiers
|
||||
|
||||
void swap (shared_ptr &__other) {
|
||||
_C_base* const __body = _C_pbody;
|
||||
element_type* const __ptr = _C_ptr;
|
||||
_C_pbody = __other._C_pbody;
|
||||
_C_ptr = __other._C_ptr;
|
||||
__other._C_pbody = __body;
|
||||
__other._C_ptr = __ptr;
|
||||
}
|
||||
|
||||
void reset () {
|
||||
if (_C_pbody) {
|
||||
_C_pbody->_C_unref ();
|
||||
_C_pbody = 0;
|
||||
_C_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
void reset (_TypeU *__ptr) {
|
||||
shared_ptr<_TypeU>(__ptr).swap (*this);
|
||||
}
|
||||
|
||||
template <class _TypeU, class _Deleter>
|
||||
void reset (_TypeU *__ptr, _Deleter __del) {
|
||||
shared_ptr<_TypeU>(__ptr, __del).swap (*this);
|
||||
}
|
||||
|
||||
// [2.2.3.5] observers
|
||||
|
||||
element_type* get () const {
|
||||
return _C_ptr;
|
||||
}
|
||||
|
||||
_TYPENAME _RW::__rw_nonvoid_ref<element_type>::_C_ref
|
||||
operator*() const {
|
||||
_RWSTD_ASSERT (0 != get ());
|
||||
return *get ();
|
||||
}
|
||||
|
||||
element_type* operator->() const {
|
||||
return &**this;
|
||||
}
|
||||
|
||||
long use_count () const {
|
||||
return _C_pbody ? _C_pbody->_C_get_ref () : 0;
|
||||
}
|
||||
|
||||
bool unique () const {
|
||||
return 1 == use_count ();
|
||||
}
|
||||
|
||||
operator bool () const {
|
||||
return 0 != get ();
|
||||
}
|
||||
|
||||
template <class _Deleter>
|
||||
_Deleter* _C_get_deleter () const {
|
||||
return _RWSTD_STATIC_CAST (_Deleter*,
|
||||
_C_pbody ? _C_pbody->_C_get_deleter () : 0);
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
bool _C_less (const shared_ptr<_TypeU> &__rhs) const {
|
||||
return _C_pbody < __rhs._C_pbody;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// helper to check whether one pointer is convertible to another
|
||||
// and to enforce the convertibility requirements
|
||||
static void _C_is_convertible (element_type*) { }
|
||||
};
|
||||
|
||||
|
||||
// 2.2.3.6 - shared_ptr comparisons
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline bool
|
||||
operator== (const shared_ptr<_TypeT> &__lhs, const shared_ptr<_TypeU> &__rhs)
|
||||
{
|
||||
return __lhs.get () == __rhs.get ();
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline bool
|
||||
operator!= (const shared_ptr<_TypeT> &__lhs, const shared_ptr<_TypeU> &__rhs)
|
||||
{
|
||||
return __lhs.get () != __rhs.get ();
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline bool
|
||||
operator< (const shared_ptr<_TypeT> &__lhs, const shared_ptr<_TypeU> &__rhs)
|
||||
{
|
||||
return __lhs._C_less (__rhs);
|
||||
}
|
||||
|
||||
|
||||
// 2.2.3.8 - shared_ptr specialized algorithms
|
||||
template <class _TypeT>
|
||||
inline void
|
||||
swap (shared_ptr<_TypeT> &__lhs, shared_ptr<_TypeT> &__rhs)
|
||||
{
|
||||
__lhs.swap (__rhs);
|
||||
}
|
||||
|
||||
|
||||
// 2.2.3.9 - shared_ptr casts
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline shared_ptr<_TypeT>
|
||||
static_pointer_cast (const shared_ptr<_TypeU> &__src)
|
||||
{
|
||||
_TypeT* const __ptr = _RWSTD_STATIC_CAST (_TypeT*, __src.get ());
|
||||
if (__ptr)
|
||||
return shared_ptr<_TypeT>(__src, __ptr);
|
||||
|
||||
return shared_ptr<_TypeT>();
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline shared_ptr<_TypeT>
|
||||
dynamic_pointer_cast (const shared_ptr<_TypeU> &__src)
|
||||
{
|
||||
_TypeT* const __ptr = _RWSTD_DYNAMIC_CAST (_TypeT*, __src.get ());
|
||||
if (__ptr)
|
||||
return shared_ptr<_TypeT>(__src, __ptr);
|
||||
|
||||
return shared_ptr<_TypeT>();
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline shared_ptr<_TypeT>
|
||||
const_pointer_cast (const shared_ptr<_TypeU> &__src)
|
||||
{
|
||||
_TypeT* const __ptr = _RWSTD_CONST_CAST (_TypeT*, __src.get ());
|
||||
if (__ptr)
|
||||
return shared_ptr<_TypeT>(__src, __ptr);
|
||||
|
||||
return shared_ptr<_TypeT>();
|
||||
}
|
||||
|
||||
|
||||
#if 0 // NOT IMPLEMENTED YET
|
||||
|
||||
// 2.2.3.7 - shared_ptr I/O
|
||||
template <class _CharT, class _Traits, class _TypeT>
|
||||
inline basic_ostream<_CharT, _TypeT>&
|
||||
operator<< (basic_ostream<_CharT, _Traits>&, const shared_ptr<_TypeT>&);
|
||||
|
||||
#endif // 0/1
|
||||
|
||||
|
||||
// 2.2.3.10 - shared_ptr get_deleter
|
||||
template <class _Deleter, class _TypeT>
|
||||
_Deleter*
|
||||
get_deleter (const shared_ptr<_TypeT> &__ptr)
|
||||
{
|
||||
return __ptr._C_get_deleter ();
|
||||
}
|
||||
|
||||
|
||||
// 2.2.4 - class template weak_ptr
|
||||
template <class _TypeT>
|
||||
class weak_ptr
|
||||
{
|
||||
// declare every specialization a friend and grant
|
||||
// template members access to _C_pbody
|
||||
template <class _TypeU>
|
||||
friend class weak_ptr;
|
||||
|
||||
template <class _TypeU>
|
||||
friend class shared_ptr;
|
||||
|
||||
typedef _RW::__rw_ptr_base _C_base;
|
||||
|
||||
_C_base *_C_pbody;
|
||||
_TypeT *_C_ptr;
|
||||
|
||||
public:
|
||||
|
||||
typedef _TypeT element_type;
|
||||
|
||||
// constructors
|
||||
weak_ptr (): _C_pbody (0), _C_ptr (0) { }
|
||||
|
||||
template <class _TypeU>
|
||||
weak_ptr (const shared_ptr<_TypeU> &__ptr)
|
||||
: _C_pbody (__ptr._C_pbody), _C_ptr (__ptr._C_ptr) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
}
|
||||
|
||||
weak_ptr (const weak_ptr &__rhs)
|
||||
: _C_pbody (__rhs._C_pbody), _C_ptr (__rhs._C_ptr) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
weak_ptr (const weak_ptr<_TypeU> &__rhs)
|
||||
: _C_pbody (__rhs._C_pbody), _C_ptr (__rhs._C_ptr) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
}
|
||||
|
||||
// destructor
|
||||
~weak_ptr () {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref_weak ();
|
||||
|
||||
#ifdef _RWSTDDEBUG
|
||||
_C_pbody = (_C_base*)0xdeadbeefL;
|
||||
_C_ptr = (element_type*)0xdeadbeefL;
|
||||
#endif // _RWSTDDEBUG
|
||||
}
|
||||
|
||||
// assignment
|
||||
weak_ptr& operator= (const weak_ptr &__rhs) {
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref_weak ();
|
||||
if ((_C_pbody = __rhs._C_pbody))
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
_C_ptr = __rhs._C_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _TypeU>
|
||||
weak_ptr& operator= (const weak_ptr<_TypeU> &__rhs) {
|
||||
_C_is_convertible ((_TypeU*)0);
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref_weak ();
|
||||
if ((_C_pbody = __rhs._C_pbody))
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
_C_ptr = __rhs._C_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class _TypeU>
|
||||
weak_ptr& operator=(const shared_ptr<_TypeU> &__rhs) {
|
||||
_C_is_convertible ((_TypeU*)0);
|
||||
if (_C_pbody)
|
||||
_C_pbody->_C_unref_weak ();
|
||||
if ((_C_pbody = __rhs._C_pbody))
|
||||
_C_pbody->_C_inc_ref_weak ();
|
||||
_C_ptr = __rhs._C_ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// modifiers
|
||||
|
||||
void swap (weak_ptr &__other) {
|
||||
_C_base* const __body = _C_pbody;
|
||||
element_type* const __ptr = _C_ptr;
|
||||
_C_pbody = __other._C_pbody;
|
||||
_C_ptr = __other._C_ptr;
|
||||
__other._C_pbody = __body;
|
||||
__other._C_ptr = __ptr;
|
||||
}
|
||||
|
||||
void reset () {
|
||||
if (_C_pbody) {
|
||||
_C_pbody->_C_unref_weak ();
|
||||
_C_pbody = 0;
|
||||
_C_ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// observers
|
||||
long use_count () const {
|
||||
return _C_pbody ? _C_pbody->_C_get_ref () : 0;
|
||||
}
|
||||
|
||||
bool expired () const {
|
||||
return 0 == use_count ();
|
||||
}
|
||||
|
||||
shared_ptr<element_type>
|
||||
lock () const {
|
||||
return expired () ? shared_ptr<element_type>()
|
||||
: shared_ptr<element_type>(*this);
|
||||
}
|
||||
|
||||
// implements 2.2.4.6 - non-member template operator<
|
||||
template <class _TypeU>
|
||||
bool operator< (const weak_ptr<_TypeU> __rhs) const {
|
||||
return _C_pbody < __rhs._C_pbody;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// helper to check whether one pointer is convertible to another
|
||||
// and to enforce the convertibility requirements
|
||||
static void _C_is_convertible (element_type*) { }
|
||||
};
|
||||
|
||||
|
||||
// 2.2.4.6 - weak_ptr comparison
|
||||
template <class _TypeT, class _TypeU>
|
||||
inline bool
|
||||
operator< (const weak_ptr<_TypeT> &__lhs, const weak_ptr<_TypeU> &__rhs)
|
||||
{
|
||||
return __lhs.operator< (__rhs);
|
||||
}
|
||||
|
||||
|
||||
// 2.2.4.7 - weak_ptr specialized algorithms
|
||||
template <class _TypeT>
|
||||
inline void
|
||||
swap (weak_ptr<_TypeT> &__lhs, weak_ptr<_TypeT> &__rhs)
|
||||
{
|
||||
__lhs.swap (__rhs);
|
||||
}
|
||||
|
||||
|
||||
// 2.2.5 - class enable_shared_from_this
|
||||
template <class _TypeT>
|
||||
class enable_shared_from_this;
|
||||
|
||||
|
||||
} // namespace tr1
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
#endif // _RWSTD_TR1_SMARTPTR_INCLUDED
|
||||
372
extern/stdcxx/4.2.1/include/tr1/array
vendored
Normal file
372
extern/stdcxx/4.2.1/include/tr1/array
vendored
Normal file
@@ -0,0 +1,372 @@
|
||||
// -*- C++ -*-
|
||||
/***************************************************************************
|
||||
*
|
||||
* array - definition of class template array
|
||||
*
|
||||
* $Id: array 550991 2007-06-26 23:58:07Z sebor $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 1994-2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _RWSTD_TR1_ARRAY_INCLUDED
|
||||
#define _RWSTD_TR1_ARRAY_INCLUDED
|
||||
|
||||
|
||||
#include <rw/_algobase.h>
|
||||
#include <rw/_error.h>
|
||||
#include <rw/_iterator.h>
|
||||
#include <rw/_defs.h>
|
||||
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
_RWSTD_NAMESPACE (tr1) {
|
||||
|
||||
|
||||
// 6.2.2 -- class template array
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
struct array
|
||||
{
|
||||
// types:
|
||||
typedef _TypeT value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef _RWSTD_SIZE_T size_type;
|
||||
typedef _RWSTD_PTRDIFF_T difference_type;
|
||||
|
||||
#ifndef _RWSTD_NO_DEBUG_ITER
|
||||
|
||||
typedef _RW::__rw_debug_iter <array, pointer, pointer> iterator;
|
||||
|
||||
typedef _RW::__rw_debug_iter <array, const_pointer, pointer> const_iterator;
|
||||
|
||||
iterator _C_make_iter (pointer __ptr) {
|
||||
return iterator (*this, __ptr);
|
||||
}
|
||||
|
||||
const_iterator _C_make_iter (const_pointer __ptr) const {
|
||||
return const_iterator (*this, __ptr);
|
||||
}
|
||||
|
||||
#else // if defined (_RWSTD_NO_DEBUG_ITER)
|
||||
|
||||
typedef pointer iterator;
|
||||
typedef const_pointer const_iterator;
|
||||
|
||||
iterator _C_make_iter (pointer __ptr) {
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
const_iterator _C_make_iter (const_pointer __ptr) const {
|
||||
return __ptr;
|
||||
}
|
||||
|
||||
#endif // _RWSTD_NO_DEBUG_ITER
|
||||
|
||||
typedef _RWSTD_REVERSE_ITERATOR (iterator,
|
||||
reference,
|
||||
pointer,
|
||||
random_access_iterator_tag)
|
||||
reverse_iterator;
|
||||
|
||||
typedef _RWSTD_REVERSE_ITERATOR (const_iterator,
|
||||
const_reference,
|
||||
const_pointer,
|
||||
random_access_iterator_tag)
|
||||
const_reverse_iterator;
|
||||
|
||||
// No explicit construct/copy/destroy for aggregate type
|
||||
void assign (const_reference);
|
||||
void swap (array&);
|
||||
|
||||
// iterators:
|
||||
iterator begin () {
|
||||
return _C_make_iter (data ());
|
||||
}
|
||||
|
||||
const_iterator begin () const {
|
||||
return _C_make_iter (data ());
|
||||
}
|
||||
|
||||
iterator end () {
|
||||
return _C_make_iter (data () + size ());
|
||||
}
|
||||
|
||||
const_iterator end () const {
|
||||
return _C_make_iter (data () + size ());
|
||||
}
|
||||
|
||||
reverse_iterator rbegin () {
|
||||
return reverse_iterator (end ());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin () const {
|
||||
return const_reverse_iterator (end ());
|
||||
}
|
||||
|
||||
reverse_iterator rend () {
|
||||
return reverse_iterator (begin ());
|
||||
}
|
||||
|
||||
const_reverse_iterator rend () const {
|
||||
return const_reverse_iterator (begin ());
|
||||
}
|
||||
|
||||
// capacity:
|
||||
size_type size () const {
|
||||
return _Size;
|
||||
}
|
||||
|
||||
size_type max_size () const {
|
||||
return _Size;
|
||||
}
|
||||
|
||||
bool empty () const {
|
||||
return 0 == size ();
|
||||
}
|
||||
|
||||
// element access:
|
||||
reference operator[] (size_type);
|
||||
const_reference operator[] (size_type) const;
|
||||
|
||||
const_reference at (size_type) const;
|
||||
reference at (size_type);
|
||||
|
||||
reference front () {
|
||||
_RWSTD_ASSERT (!empty ());
|
||||
return *data ();
|
||||
}
|
||||
|
||||
const_reference front () const {
|
||||
_RWSTD_ASSERT (!empty ());
|
||||
return *data ();
|
||||
}
|
||||
|
||||
reference back () {
|
||||
_RWSTD_ASSERT (!empty ());
|
||||
return data () [size () - 1];
|
||||
}
|
||||
|
||||
const_reference back () const {
|
||||
_RWSTD_ASSERT (!empty ());
|
||||
return data () [size () - 1];
|
||||
}
|
||||
|
||||
pointer data () {
|
||||
return _C_elems;
|
||||
}
|
||||
|
||||
const_pointer data () const {
|
||||
return _C_elems;
|
||||
}
|
||||
|
||||
// private: (no public/protected/private in aggregate types)
|
||||
value_type _C_elems [_Size];
|
||||
};
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline void
|
||||
array<_TypeT, _Size>::
|
||||
assign (const_reference __val)
|
||||
{
|
||||
const pointer __end = data () + size ();
|
||||
|
||||
for (pointer __ptr = data (); __ptr != __end; ++__ptr)
|
||||
*__ptr = __val;
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline void
|
||||
array<_TypeT, _Size>::
|
||||
swap (array<_TypeT, _Size> &__other)
|
||||
{
|
||||
_RWSTD_ASSERT (size () == __other.size ());
|
||||
|
||||
const array __tmp (*this);
|
||||
*this = __other;
|
||||
__other = __tmp;
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline _TYPENAME array<_TypeT, _Size>::reference
|
||||
array<_TypeT, _Size>::
|
||||
operator[] (size_type __inx)
|
||||
{
|
||||
#ifdef _RWSTD_BOUNDS_CHECKING
|
||||
|
||||
_RWSTD_REQUIRES (__inx < size (),
|
||||
(_RWSTD_ERROR_OUT_OF_RANGE,
|
||||
_RWSTD_FUNC ("array::operator[](size_type)"),
|
||||
__inx, size ()));
|
||||
|
||||
#endif // _RWSTD_BOUNDS_CHECKING
|
||||
|
||||
return data ()[__inx];
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline _TYPENAME array<_TypeT, _Size>::const_reference
|
||||
array<_TypeT, _Size>::
|
||||
operator[] (size_type __inx) const
|
||||
{
|
||||
#ifdef _RWSTD_BOUNDS_CHECKING
|
||||
|
||||
_RWSTD_REQUIRES (__inx < size (),
|
||||
(_RWSTD_ERROR_OUT_OF_RANGE,
|
||||
_RWSTD_FUNC ("array::operator[](size_type) const"),
|
||||
__inx, size ()));
|
||||
|
||||
#endif // _RWSTD_BOUNDS_CHECKING
|
||||
|
||||
return data ()[__inx];
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline _TYPENAME array<_TypeT, _Size>::reference
|
||||
array<_TypeT, _Size>::
|
||||
at (size_type __inx)
|
||||
{
|
||||
_RWSTD_REQUIRES (__inx < size (),
|
||||
(_RWSTD_ERROR_OUT_OF_RANGE,
|
||||
_RWSTD_FUNC ("array::at (size_type)"),
|
||||
__inx, size ()));
|
||||
|
||||
return data ()[__inx];
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline _TYPENAME array<_TypeT, _Size>::const_reference
|
||||
array<_TypeT, _Size>::
|
||||
at (size_type __inx) const
|
||||
{
|
||||
_RWSTD_REQUIRES (__inx < size (),
|
||||
(_RWSTD_ERROR_OUT_OF_RANGE,
|
||||
_RWSTD_FUNC ("array::at(size_type) const"),
|
||||
__inx, size ()));
|
||||
return data ()[__inx];
|
||||
}
|
||||
|
||||
|
||||
// array comparisons
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator== (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
_RWSTD_ASSERT (__lhs.size () == __rhs.size ());
|
||||
|
||||
return _STD::equal (__lhs.begin (), __lhs.end (), __rhs.begin ());
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator< (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
_RWSTD_ASSERT (__lhs.size () == __rhs.size ());
|
||||
|
||||
return _STD::lexicographical_compare (__lhs.begin (), __lhs.end (),
|
||||
__rhs.begin (), __rhs.end ());
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator!= (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
return !(__lhs == __rhs);
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator> (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
return __rhs < __lhs;
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator>= (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
return !(__lhs < __rhs);
|
||||
}
|
||||
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
inline bool
|
||||
operator<= (const array<_TypeT, _Size> &__lhs,
|
||||
const array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
return !(__rhs < __lhs);
|
||||
}
|
||||
|
||||
|
||||
// 6.2.2.2 -- specialized algorithms
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size >
|
||||
inline void
|
||||
swap (array<_TypeT, _Size> &__lhs, array<_TypeT, _Size> &__rhs)
|
||||
{
|
||||
__lhs.swap (__rhs);
|
||||
}
|
||||
|
||||
|
||||
// 6.2.2.5 -- tuple interface to class template array
|
||||
template <class _TypeT>
|
||||
class tuple_size; // defined in <tr1/tuple>
|
||||
|
||||
template <int I, class _TypeT>
|
||||
class tuple_element; // defined in <tr1/tuple>
|
||||
|
||||
template <class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
struct tuple_size<array<_TypeT, _Size> >;
|
||||
|
||||
template <int I, class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
struct tuple_element<I, array<_TypeT, _Size> >;
|
||||
|
||||
template <int I, class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
_TypeT& get (array<_TypeT, _Size>&);
|
||||
|
||||
template <int I, class _TypeT, _RWSTD_SIZE_T _Size>
|
||||
const _TypeT& get (const array<_TypeT, _Size>&);
|
||||
|
||||
|
||||
} // namespace tr1
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
#endif // _RWSTD_TR1_ARRAY_INCLUDED
|
||||
359
extern/stdcxx/4.2.1/include/tr1/cstdint
vendored
Normal file
359
extern/stdcxx/4.2.1/include/tr1/cstdint
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
// -*- C++ -*-
|
||||
/***************************************************************************
|
||||
*
|
||||
* cstdint - definition of integer types [tr.c99.cstdint]
|
||||
*
|
||||
* $Id: cstdint 590052 2007-10-30 12:44:14Z faridz $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _RWSTD_TR1_CSTDINT_INCLUDED
|
||||
#define _RWSTD_TR1_CSTDINT_INCLUDED
|
||||
|
||||
|
||||
#include <rw/_defs.h>
|
||||
|
||||
|
||||
_RWSTD_NAMESPACE (std) {
|
||||
|
||||
_RWSTD_NAMESPACE (tr1) {
|
||||
|
||||
#ifndef _RWSTD_BNO_TWOS_COMPLEMENT
|
||||
# define _RWSTD_T_MIN(tmax) (-(tmax) - 1)
|
||||
#else
|
||||
# define _RWSTD_T_MIN(tmax) -(tmax)
|
||||
#endif
|
||||
|
||||
|
||||
/*** int8_t ***************************************************************/
|
||||
|
||||
#ifdef _RWSTD_INT8_T
|
||||
|
||||
// optional exact width types
|
||||
typedef _RWSTD_INT8_T int8_t;
|
||||
typedef _RWSTD_UINT8_T uint8_t;
|
||||
|
||||
# define INT8_MAX 127
|
||||
# define UINT8_MAX 255U
|
||||
# define INT_LEAST8_MAX INT8_MAX
|
||||
# define UINT_LEAST8_MAX UINT8_MAX
|
||||
# define INT_FAST8_MAX INT8_MAX
|
||||
# define UINT_FAST8_MAX UINT8_MAX
|
||||
|
||||
#elif defined (_RWSTD_INT16_T)
|
||||
|
||||
# define INT_LEAST8_MAX 32767
|
||||
# define UINT_LEAST8_MAX 65535U
|
||||
# define INT_FAST8_MAX 32767
|
||||
# define UINT_FAST8_MAX 65535U
|
||||
|
||||
#elif defined (_RWSTD_INT32_T)
|
||||
|
||||
# if 4 == _RWSTD_INT_SIZE
|
||||
# define INT_LEAST8_MAX _RWSTD_INT_MAX
|
||||
# define UINT_LEAST8_MAX _RWSTD_UINT_MAX
|
||||
# define INT_FAST8_MAX _RWSTD_INT_MAX
|
||||
# define UINT_FAST8_MAX _RWSTD_UINT_MAX
|
||||
# elif 4 == _RWSTD_LONG_SIZE
|
||||
# define INT_LEAST8_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_LEAST8_MAX _RWSTD_ULONG_MAX
|
||||
# define INT_FAST8_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_FAST8_MAX _RWSTD_ULONG_MAX
|
||||
# endif
|
||||
|
||||
#elif defined (_RWSTD_INT64_T)
|
||||
|
||||
# if 8 == _RWSTD_LONG_SIZE
|
||||
# define INT_LEAST8_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_LEAST8_MAX _RWSTD_ULONG_MAX
|
||||
# define INT_FAST8_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_FAST8_MAX _RWSTD_ULONG_MAX
|
||||
# elif 8 == _RWSTD_LLONG_SIZE
|
||||
# define INT_LEAST8_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_LEAST8_MAX _RWSTD_ULLONG_MAX
|
||||
# define INT_FAST8_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_FAST8_MAX _RWSTD_ULLONG_MAX
|
||||
# endif
|
||||
|
||||
#else // fallback on int
|
||||
|
||||
# define INT_LEAST8_MAX _RWSTD_INT_MAX
|
||||
# define UINT_LEAST8_MAX _RWSTD_UINT_MAX
|
||||
# define INT_FAST8_MAX _RWSTD_INT_MAX
|
||||
# define UINT_FAST8_MAX _RWSTD_UINT_MAX
|
||||
|
||||
#endif // _RWSTD_INT{8,16,32,64}_T
|
||||
|
||||
|
||||
/*** int16_t **************************************************************/
|
||||
|
||||
#ifdef _RWSTD_INT16_T
|
||||
|
||||
// optional exact width types
|
||||
typedef _RWSTD_INT16_T int16_t;
|
||||
typedef _RWSTD_UINT16_T uint16_t;
|
||||
|
||||
# define INT16_MAX 32767
|
||||
# define UINT16_MAX 65535U
|
||||
|
||||
# define INT_LEAST16_MAX INT16_MAX
|
||||
# define UINT_LEAST16_MAX UINT16_MAX
|
||||
# define INT_FAST16_MAX INT16_MAX
|
||||
# define UINT_FAST16_MAX UINT16_MAX
|
||||
|
||||
#elif defined (_RWSTD_INT32_T)
|
||||
|
||||
# if 4 == _RWSTD_INT_SIZE
|
||||
# define INT_LEAST16_MAX _RWSTD_INT_MAX
|
||||
# define UINT_LEAST16_MAX _RWSTD_UINT_MAX
|
||||
# define INT_FAST16_MAX _RWSTD_INT_MAX
|
||||
# define UINT_FAST16_MAX _RWSTD_UINT_MAX
|
||||
# elif 4 == _RWSTD_LONG_SIZE
|
||||
# define INT_LEAST16_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_LEAST16_MAX _RWSTD_ULONG_MAX
|
||||
# define INT_FAST16_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_FAST16_MAX _RWSTD_ULONG_MAX
|
||||
# endif
|
||||
|
||||
#elif defined (_RWSTD_INT64_T)
|
||||
|
||||
# if 8 == _RWSTD_LONG_SIZE
|
||||
# define INT_LEAST16_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_LEAST16_MAX _RWSTD_ULONG_MAX
|
||||
# define INT_FAST16_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_FAST16_MAX _RWSTD_ULONG_MAX
|
||||
# elif 8 == _RWSTD_LLONG_SIZE
|
||||
# define INT_LEAST16_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_LEAST16_MAX _RWSTD_ULLONG_MAX
|
||||
# define INT_FAST16_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_FAST16_MAX _RWSTD_ULLONG_MAX
|
||||
# endif
|
||||
|
||||
#else // fallback on int
|
||||
|
||||
# define INT_LEAST16_MAX _RWSTD_INT_MAX
|
||||
# define UINT_LEAST16_MAX _RWSTD_UINT_MAX
|
||||
# define INT_FAST16_MAX _RWSTD_INT_MAX
|
||||
# define UINT_FAST16_MAX _RWSTD_UINT_MAX
|
||||
|
||||
#endif // _RWSTD_INT{16,32,64}_T
|
||||
|
||||
|
||||
/*** int32_t **************************************************************/
|
||||
|
||||
#ifdef _RWSTD_INT32_T
|
||||
|
||||
// optional exact width types
|
||||
typedef _RWSTD_INT32_T int32_t;
|
||||
typedef _RWSTD_UINT32_T uint32_t;
|
||||
|
||||
# if 4 == _RWSTD_INT_SIZE
|
||||
# define INT32_MAX _RWSTD_INT_MAX
|
||||
# define UINT32_MAX _RWSTD_UINT_MAX
|
||||
# elif 4 == _RWSTD_LONG_SIZE
|
||||
# define INT32_MAX _RWSTD_LONG_MAX
|
||||
# define UINT32_MAX _RWSTD_LONG_MAX
|
||||
# endif
|
||||
|
||||
# define INT_LEAST32_MAX INT32_MAX
|
||||
# define UINT_LEAST32_MAX UINT32_MAX
|
||||
# define INT_FAST32_MAX INT32_MAX
|
||||
# define UINT_FAST32_MAX UINT32_MAX
|
||||
|
||||
#elif defined (_RWSTD_INT64_T)
|
||||
|
||||
# if 8 == _RWSTD_LONG_SIZE
|
||||
# define INT_LEAST32_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_LEAST32_MAX _RWSTD_ULONG_MAX
|
||||
# define INT_FAST32_MAX _RWSTD_LONG_MAX
|
||||
# define UINT_FAST32_MAX _RWSTD_ULONG_MAX
|
||||
# elif 8 == _RWSTD_LLONG_SIZE
|
||||
# define INT_LEAST32_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_LEAST32_MAX _RWSTD_ULLONG_MAX
|
||||
# define INT_FAST32_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT_FAST32_MAX _RWSTD_ULLONG_MAX
|
||||
# endif
|
||||
|
||||
#else // fallback on int
|
||||
|
||||
# define INT32_MAX _RWSTD_INT_MAX
|
||||
# define UINT32_MAX _RWSTD_UINT_MAX
|
||||
# define INT_LEAST32_MAX _RWSTD_INT_MAX
|
||||
# define UINT_LEAST32_MAX _RWSTD_UINT_MAX
|
||||
# define INT_FAST32_MAX _RWSTD_INT_MAX
|
||||
# define UINT_FAST32_MAX _RWSTD_UINT_MAX
|
||||
|
||||
#endif // _RWSTD_INT{32,64}_T
|
||||
|
||||
|
||||
/*** int64_t **************************************************************/
|
||||
|
||||
#ifdef _RWSTD_INT64_T
|
||||
|
||||
// optional exact width types
|
||||
typedef _RWSTD_INT64_T int64_t;
|
||||
typedef _RWSTD_UINT64_T uint64_t;
|
||||
|
||||
// 7.18.2.5 of C99 requires that intmax_t be at least 64-bits wide
|
||||
typedef _RWSTD_INT64_T intmax_t;
|
||||
typedef _RWSTD_UINT64_T uintmax_t;
|
||||
|
||||
# if 8 == _RWSTD_LONG_SIZE
|
||||
# define INT64_MAX _RWSTD_LONG_MAX
|
||||
# define UINT64_MAX _RWSTD_ULONG_MAX
|
||||
# elif 8 == _RWSTD_LLONG_SIZE
|
||||
# define INT64_MAX _RWSTD_LLONG_MAX
|
||||
# define UINT64_MAX _RWSTD_ULLONG_MAX
|
||||
# endif
|
||||
|
||||
# define INT_LEAST64_MAX INT64_MAX
|
||||
# define UINT_LEAST64_MAX UINT64_MAX
|
||||
# define INT_FAST64_MAX INT64_MAX
|
||||
# define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
#elif defined (_RWSTD_LONG_LONG) // fallback on long long
|
||||
|
||||
// this possibly violates 7.18.2.5 of C99 which requires that intmax_t
|
||||
// be at least 64-bits wide
|
||||
typedef _RWSTD_LONG_LONG intmax_t;
|
||||
typedef unsigned _RWSTD_LONG_LONG uintmax_t;
|
||||
|
||||
#else // fallback on long
|
||||
|
||||
// this likely violates 7.18.2.5 of C99 which requires that intmax_t
|
||||
// be at least 64-bits wide
|
||||
typedef long intmax_t;
|
||||
typedef unsigned long uintmax_t;
|
||||
|
||||
#endif // _RWSTD_INT{64,32,16}_T
|
||||
|
||||
/*** intptr_t *************************************************************/
|
||||
|
||||
#if 8 == _RWSTD_PTR_SIZE
|
||||
|
||||
typedef _RWSTD_INT64_T intptr_t;
|
||||
typedef _RWSTD_UINT64_T uintptr_t;
|
||||
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
|
||||
#elif 4 == _RWSTD_PTR_SIZE
|
||||
|
||||
typedef _RWSTD_INT32_T intptr_t;
|
||||
typedef _RWSTD_UINT32_T uintptr_t;
|
||||
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
|
||||
#elif 2 == _RWSTD_PTR_SIZE
|
||||
|
||||
typedef _RWSTD_INT16_T intptr_t;
|
||||
typedef _RWSTD_UINT16_T uintptr_t;
|
||||
|
||||
# define INTPTR_MAX INT16_MAX
|
||||
# define UINTPTR_MAX UINT16_MAX
|
||||
|
||||
#else // fallback on long
|
||||
|
||||
typedef long intptr_t;
|
||||
typedef unsigned long uintptr_t;
|
||||
|
||||
# define INTPTR_MAX _RWSTD_LONG_MAX
|
||||
# define UINTPTR_MAX _RWSTD_LONG_MAX
|
||||
|
||||
#endif // {8,16,32,64} == _RWSTD_PTR_SIZE
|
||||
|
||||
/*** least and fast types *************************************************/
|
||||
|
||||
typedef _RWSTD_INT_LEAST8_T int_least8_t;
|
||||
typedef _RWSTD_UINT_LEAST8_T uint_least8_t;
|
||||
typedef _RWSTD_INT_LEAST8_T int_fast8_t;
|
||||
typedef _RWSTD_UINT_LEAST8_T uint_fast8_t;
|
||||
|
||||
typedef _RWSTD_INT_LEAST16_T int_least16_t;
|
||||
typedef _RWSTD_UINT_LEAST16_T uint_least16_t;
|
||||
typedef _RWSTD_INT_LEAST16_T int_fast16_t;
|
||||
typedef _RWSTD_UINT_LEAST16_T uint_fast16_t;
|
||||
|
||||
typedef _RWSTD_INT_LEAST32_T int_least32_t;
|
||||
typedef _RWSTD_UINT_LEAST32_T uint_least32_t;
|
||||
typedef _RWSTD_INT_LEAST32_T int_fast32_t;
|
||||
typedef _RWSTD_UINT_LEAST32_T uint_fast32_t;
|
||||
|
||||
#ifdef _RWSTD_INT_LEAST64_T
|
||||
|
||||
typedef _RWSTD_INT_LEAST64_T int_least64_t;
|
||||
typedef _RWSTD_UINT_LEAST64_T uint_least64_t;
|
||||
typedef _RWSTD_INT_LEAST64_T int_fast64_t;
|
||||
typedef _RWSTD_UINT_LEAST64_T uint_fast64_t;
|
||||
|
||||
#endif // _RWSTD_INT_LEAST64_T
|
||||
|
||||
#ifdef _RWSTD_INT_LEAST128_T
|
||||
|
||||
typedef _RWSTD_INT_LEAST128_T int_least128_t;
|
||||
typedef _RWSTD_UINT_LEAST128_T uint_least128_t;
|
||||
typedef _RWSTD_INT_LEAST128_T int_fast128_t;
|
||||
typedef _RWSTD_UINT_LEAST128_T uint_fast128_t;
|
||||
|
||||
#endif // _RWSTD_INT_LEAST128_T
|
||||
|
||||
/*** other constants ******************************************************/
|
||||
|
||||
#define PTRDIFF_MIN _RWSTD_PTRDIFF_MIN
|
||||
#define PTRDIFF_MAX _RWSTD_PTRDIFF_MAX
|
||||
|
||||
#define SIZE_MAX _RWSTD_SIZE_MAX
|
||||
|
||||
#define WCHAR_MIN _RWSTD_WCHAR_MIN
|
||||
#define WCHAR_MAX _RWSTD_WCHAR_MAX
|
||||
|
||||
#define WINT_MIN _RWSTD_WINT_MIN
|
||||
#define WINT_MAX _RWSTD_WINT_MAX
|
||||
|
||||
#define SIG_ATOMIC_MIN _RWSTD_SIG_ATOMIC_MIN
|
||||
#define SIG_ATOMIC_MAX _RWSTD_SIG_ATOMIC_MAX
|
||||
|
||||
/*** computed _MIN constants **********************************************/
|
||||
|
||||
#define INT8_MIN _RWSTD_T_MIN (INT8_MAX)
|
||||
#define INT16_MIN _RWSTD_T_MIN (INT16_MAX)
|
||||
#define INT32_MIN _RWSTD_T_MIN (INT32_MAX)
|
||||
#define INT64_MIN _RWSTD_T_MIN (INT64_MAX)
|
||||
|
||||
#define INT_LEAST8_MIN _RWSTD_T_MIN (INT_LEAST8_MAX)
|
||||
#define INT_LEAST16_MIN _RWSTD_T_MIN (INT_LEAST16_MAX)
|
||||
#define INT_LEAST32_MIN _RWSTD_T_MIN (INT_LEAST32_MAX)
|
||||
#define INT_LEAST64_MIN _RWSTD_T_MIN (INT_LEAST64_MAX)
|
||||
|
||||
#define INT_FAST8_MIN _RWSTD_T_MIN (INT_FAST8_MAX)
|
||||
#define INT_FAST16_MIN _RWSTD_T_MIN (INT_FAST16_MAX)
|
||||
#define INT_FAST32_MIN _RWSTD_T_MIN (INT_FAST32_MAX)
|
||||
#define INT_FAST64_MIN _RWSTD_T_MIN (INT_FAST64_MAX)
|
||||
|
||||
} // namespace tr1
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
||||
#endif // _RWSTD_TR1_CSTDINT_INCLUDED
|
||||
99
extern/stdcxx/4.2.1/include/tr1/stdint.h
vendored
Normal file
99
extern/stdcxx/4.2.1/include/tr1/stdint.h
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// -*- C++ -*-
|
||||
/***************************************************************************
|
||||
*
|
||||
* stdint.h - definition of integer types [tr.c99.stdinth]
|
||||
*
|
||||
* $Id: stdint.h 590052 2007-10-30 12:44:14Z faridz $
|
||||
*
|
||||
***************************************************************************
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed
|
||||
* with this work for additional information regarding copyright
|
||||
* ownership. The ASF licenses this file to you under the Apache
|
||||
* License, Version 2.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* Copyright 2006 Rogue Wave Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _RWSTD_TR1_STDINT_H_INCLUDED
|
||||
#define _RWSTD_TR1_STDINT_H_INCLUDED
|
||||
|
||||
|
||||
#include <tr1/cstdint>
|
||||
#include <rw/_defs.h>
|
||||
|
||||
|
||||
#ifdef _RWSTD_INT8_T
|
||||
|
||||
// optional exact-width types
|
||||
_USING (std::tr1::int8_t);
|
||||
_USING (std::tr1::uint8_t);
|
||||
|
||||
#endif // _RWSTD_INT8_T
|
||||
|
||||
_USING (std::tr1::int_least8_t);
|
||||
_USING (std::tr1::uint_least8_t);
|
||||
_USING (std::tr1::int_fast8_t);
|
||||
_USING (std::tr1::uint_fast8_t);
|
||||
|
||||
|
||||
#ifdef _RWSTD_INT16_T
|
||||
|
||||
// optional exact-width types
|
||||
_USING (std::tr1::int16_t);
|
||||
_USING (std::tr1::uint16_t);
|
||||
|
||||
#endif // _RWSTD_INT16_T
|
||||
|
||||
_USING (std::tr1::int_least16_t);
|
||||
_USING (std::tr1::uint_least16_t);
|
||||
_USING (std::tr1::int_fast16_t);
|
||||
_USING (std::tr1::uint_fast16_t);
|
||||
|
||||
|
||||
#ifdef _RWSTD_INT32_T
|
||||
|
||||
// optional exact-width types
|
||||
_USING (std::tr1::int32_t);
|
||||
_USING (std::tr1::uint32_t);
|
||||
|
||||
#endif // _RWSTD_INT32_T
|
||||
|
||||
_USING (std::tr1::int_least32_t);
|
||||
_USING (std::tr1::uint_least32_t);
|
||||
_USING (std::tr1::int_fast32_t);
|
||||
_USING (std::tr1::uint_fast32_t);
|
||||
|
||||
|
||||
#ifdef _RWSTD_INT64_T
|
||||
|
||||
// optional exact-width types
|
||||
_USING (std::tr1::int64_t);
|
||||
_USING (std::tr1::uint64_t);
|
||||
|
||||
#endif // _RWSTD_INT64_T
|
||||
|
||||
_USING (std::tr1::int_least64_t);
|
||||
_USING (std::tr1::uint_least64_t);
|
||||
_USING (std::tr1::int_fast64_t);
|
||||
_USING (std::tr1::uint_fast64_t);
|
||||
|
||||
_USING (std::tr1::intmax_t);
|
||||
_USING (std::tr1::uintmax_t);
|
||||
_USING (std::tr1::intptr_t);
|
||||
_USING (std::tr1::uintptr_t);
|
||||
|
||||
|
||||
#endif // _RWSTD_TR1_STDINT_H_INCLUDED
|
||||
Reference in New Issue
Block a user