libcxx initial import

llvm-svn: 103490
This commit is contained in:
Howard Hinnant 2010-05-11 19:42:16 +00:00
parent 9132c59d43
commit 3e519524c1
3893 changed files with 1209942 additions and 0 deletions

63
libcxx/LICENSE.TXT Normal file
View File

@ -0,0 +1,63 @@
==============================================================================
LLVM Release License
==============================================================================
University of Illinois/NCSA
Open Source License
Copyright (c) 2007-2010 University of Illinois at Urbana-Champaign.
All rights reserved.
Developed by:
LLVM Team
University of Illinois at Urbana-Champaign
http://llvm.org
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal with
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimers in the
documentation and/or other materials provided with the distribution.
* Neither the names of the LLVM Team, University of Illinois at
Urbana-Champaign, nor the names of its contributors may be used to
endorse or promote products derived from this Software without specific
prior written permission.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
SOFTWARE.
==============================================================================
The LLVM software contains code written by third parties. Such software will
have its own individual LICENSE.TXT file in the directory in which it appears.
This file will describe the copyrights, license, and restrictions which apply
to that code.
The disclaimer of warranty in the University of Illinois Open Source License
applies to all code in the LLVM Distribution, and nothing in any of the
other licenses gives permission to use the names of the LLVM Team or the
University of Illinois to endorse or promote products derived from this
Software.
The following pieces of software have additional or alternate copyrights,
licenses, and/or restrictions:
Program Directory
------- ---------
<none yet>

37
libcxx/Makefile Normal file
View File

@ -0,0 +1,37 @@
##
# libcpp Makefile
##
SRCDIRS = .
DESTDIR = $(DSTROOT)
OBJROOT=.
SYMROOT=.
installsrc:: $(SRCROOT)
ditto $(SRCDIRS)/include $(SRCROOT)/include
ditto $(SRCDIRS)/lib/buildit $(SRCROOT)/lib/buildit
ditto $(SRCDIRS)/src $(SRCROOT)/src
ditto $(SRCDIRS)/Makefile $(SRCROOT)/Makefile
clean::
installhdrs::
mkdir -p $(DSTROOT)/usr/include/c++/v1
cp $(SRCDIRS)/include/* $(DSTROOT)/usr/include/c++/v1/
chown -R root:wheel $(DSTROOT)/usr/include
chmod 755 $(DSTROOT)/usr/include/c++/v1
chmod 644 $(DSTROOT)/usr/include/c++/v1/*
install:: installhdrs $(DESTDIR)
cd lib && ./buildit
ditto lib/libc++.1.dylib $(SYMROOT)/usr/lib/libc++.1.dylib
cd lib && dsymutil -o $(SYMROOT)/libc++.1.dylib.dSYM $(SYMROOT)/usr/lib/libc++.1.dylib
mkdir -p $(DSTROOT)/usr/lib
strip -u -r -x -S -o $(DSTROOT)/usr/lib/libc++.1.dylib $(SYMROOT)/usr/lib/libc++.1.dylib
cd $(DSTROOT)/usr/lib && ln -s libc++.1.dylib libc++.dylib

File diff suppressed because it is too large Load Diff

136
libcxx/include/__config Normal file
View File

@ -0,0 +1,136 @@
// -*- C++ -*-
//===--------------------------- __config ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CONFIG
#define _LIBCPP_CONFIG
#pragma GCC system_header
#define _LIBCPP_VERSION 1000
#define _LIBCPP_ABI_VERSION 1
#define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y
#define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y)
#define _LIBCPP_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION)
#ifdef __LITTLE_ENDIAN__
#if __LITTLE_ENDIAN__
#define _LIBCPP_LITTLE_ENDIAN 1
#define _LIBCPP_BIG_ENDIAN 0
#endif
#endif
#ifdef __BIG_ENDIAN__
#if __BIG_ENDIAN__
#define _LIBCPP_LITTLE_ENDIAN 0
#define _LIBCPP_BIG_ENDIAN 1
#endif
#endif
#if !defined(_LIBCPP_LITTLE_ENDIAN) || !defined(_LIBCPP_BIG_ENDIAN)
#error unable to determine endian
#endif
#ifndef _LIBCPP_VISIBILITY_TAG
#define _LIBCPP_VISIBILITY_TAG 1
#endif
#if _LIBCPP_VISIBILITY_TAG
#define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden")))
#define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
#else
#define _LIBCPP_HIDDEN
#define _LIBCPP_VISIBLE
#endif
#ifndef _LIBCPP_INLINE_VISIBILITY
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif
#ifndef _LIBCPP_EXCEPTION_ABI
#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
#endif
#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__))
#define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
#define _LIBCPP_MOVE
#endif
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
#define _LIBCPP_HAS_NO_STATIC_ASSERT
#endif
#define _LIBCPP_HAS_NO_NULLPTR
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
#define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_HAS_NO_DECLTYPE
#endif
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
#define _LIBCPP_HAS_NO_UNICODE_CHARS
#define _LIBCPP_HAS_NO_ADVANCED_SFINAE
#endif
#if defined(__clang__)
#define _LIBCPP_HAS_NO_STRONG_USING
#endif
#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES
#ifdef _LIBCPP_HAS_NO_STRONG_USING
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
#define _LIBCPP_END_NAMESPACE_STD }
#define _STD std
#else
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { namespace _LIBCPP_NAMESPACE {
#define _LIBCPP_END_NAMESPACE_STD } }
namespace std {
namespace _LIBCPP_NAMESPACE {
}
using namespace _LIBCPP_NAMESPACE __attribute__((__strong__));
}
#define _STD std::_LIBCPP_NAMESPACE
#endif
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef unsigned short char16_t;
typedef unsigned int char32_t;
#endif
#ifdef _LIBCPP_HAS_NO_STATIC_ASSERT
template <bool> struct __static_assert_test;
template <> struct __static_assert_test<true> {};
template <unsigned> struct __static_assert_check {};
#define static_assert(__b, __m) \
typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
_LIBCPP_CONCAT(__t, __LINE__)
#endif
#ifdef _LIBCPP_HAS_NO_DECLTYPE
#define decltype(x) __typeof__(x)
#endif
#if !__EXCEPTIONS
#define _LIBCPP_NO_EXCEPTIONS
#endif
#endif // _LIBCPP_CONFIG

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,523 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_FUNCTIONAL_BASE
#define _LIBCPP_FUNCTIONAL_BASE
#include <__config>
#include <type_traits>
#include <typeinfo>
#include <exception>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Arg, class _Result>
struct unary_function
{
typedef _Arg argument_type;
typedef _Result result_type;
};
template <class _Arg1, class _Arg2, class _Result>
struct binary_function
{
typedef _Arg1 first_argument_type;
typedef _Arg2 second_argument_type;
typedef _Result result_type;
};
template <class _Tp> struct hash;
template <class _Tp>
struct __has_result_type
{
private:
struct __two {char _; char __;};
template <class _Up> static __two __test(...);
template <class _Up> static char __test(typename _Up::result_type* = 0);
public:
static const bool value = sizeof(__test<_Tp>(0)) == 1;
};
#ifdef _LIBCPP_HAS_NO_VARIADICS
#include <__functional_base_03>
#else // _LIBCPP_HAS_NO_VARIADICS
// __weak_result_type
template <class _Tp>
struct __derives_from_unary_function
{
private:
struct __two {char _; char __;};
static __two __test(...);
template <class _A, class _R>
static unary_function<_A, _R>
__test(const volatile unary_function<_A, _R>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp>
struct __derives_from_binary_function
{
private:
struct __two {char _; char __;};
static __two __test(...);
template <class _A1, class _A2, class _R>
static binary_function<_A1, _A2, _R>
__test(const volatile binary_function<_A1, _A2, _R>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
struct __maybe_derive_from_unary_function // bool is true
: public __derives_from_unary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_unary_function<_Tp, false>
{
};
template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
struct __maybe_derive_from_binary_function // bool is true
: public __derives_from_binary_function<_Tp>::type
{
};
template <class _Tp>
struct __maybe_derive_from_binary_function<_Tp, false>
{
};
template <class _Tp, bool = __has_result_type<_Tp>::value>
struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
typedef typename _Tp::result_type result_type;
};
template <class _Tp>
struct __weak_result_type_imp<_Tp, false>
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
};
template <class _Tp>
struct __weak_result_type
: public __weak_result_type_imp<_Tp>
{
};
// 0 argument case
template <class _R>
struct __weak_result_type<_R ()>
{
typedef _R result_type;
};
template <class _R>
struct __weak_result_type<_R (&)()>
{
typedef _R result_type;
};
template <class _R>
struct __weak_result_type<_R (*)()>
{
typedef _R result_type;
};
// 1 argument case
template <class _R, class _A1>
struct __weak_result_type<_R (_A1)>
: public unary_function<_A1, _R>
{
};
template <class _R, class _A1>
struct __weak_result_type<_R (&)(_A1)>
: public unary_function<_A1, _R>
{
};
template <class _R, class _A1>
struct __weak_result_type<_R (*)(_A1)>
: public unary_function<_A1, _R>
{
};
template <class _R, class _C>
struct __weak_result_type<_R (_C::*)()>
: public unary_function<_C*, _R>
{
};
template <class _R, class _C>
struct __weak_result_type<_R (_C::*)() const>
: public unary_function<const _C*, _R>
{
};
template <class _R, class _C>
struct __weak_result_type<_R (_C::*)() volatile>
: public unary_function<volatile _C*, _R>
{
};
template <class _R, class _C>
struct __weak_result_type<_R (_C::*)() const volatile>
: public unary_function<const volatile _C*, _R>
{
};
// 2 argument case
template <class _R, class _A1, class _A2>
struct __weak_result_type<_R (_A1, _A2)>
: public binary_function<_A1, _A2, _R>
{
};
template <class _R, class _A1, class _A2>
struct __weak_result_type<_R (*)(_A1, _A2)>
: public binary_function<_A1, _A2, _R>
{
};
template <class _R, class _A1, class _A2>
struct __weak_result_type<_R (&)(_A1, _A2)>
: public binary_function<_A1, _A2, _R>
{
};
template <class _R, class _C, class _A1>
struct __weak_result_type<_R (_C::*)(_A1)>
: public binary_function<_C*, _A1, _R>
{
};
template <class _R, class _C, class _A1>
struct __weak_result_type<_R (_C::*)(_A1) const>
: public binary_function<const _C*, _A1, _R>
{
};
template <class _R, class _C, class _A1>
struct __weak_result_type<_R (_C::*)(_A1) volatile>
: public binary_function<volatile _C*, _A1, _R>
{
};
template <class _R, class _C, class _A1>
struct __weak_result_type<_R (_C::*)(_A1) const volatile>
: public binary_function<const volatile _C*, _A1, _R>
{
};
// 3 or more arguments
template <class _R, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_R (_A1, _A2, _A3, _A4...)>
{
typedef _R result_type;
};
template <class _R, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_R (&)(_A1, _A2, _A3, _A4...)>
{
typedef _R result_type;
};
template <class _R, class _A1, class _A2, class _A3, class ..._A4>
struct __weak_result_type<_R (*)(_A1, _A2, _A3, _A4...)>
{
typedef _R result_type;
};
template <class _R, class _C, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_R (_C::*)(_A1, _A2, _A3...)>
{
typedef _R result_type;
};
template <class _R, class _C, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_R (_C::*)(_A1, _A2, _A3...) const>
{
typedef _R result_type;
};
template <class _R, class _C, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_R (_C::*)(_A1, _A2, _A3...) volatile>
{
typedef _R result_type;
};
template <class _R, class _C, class _A1, class _A2, class ..._A3>
struct __weak_result_type<_R (_C::*)(_A1, _A2, _A3...) const volatile>
{
typedef _R result_type;
};
// __invoke
// first bullet
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...), _T1&& __t1, _Arg&& ...__arg)
{
return (_STD::forward<_T>(__t1).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) const, _T1&& __t1, _Arg&& ...__arg)
{
return (_STD::forward<_T>(__t1).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) volatile, _T1&& __t1, _Arg&& ...__arg)
{
return (_STD::forward<_T>(__t1).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) const volatile, _T1&& __t1, _Arg&& ...__arg)
{
return (_STD::forward<_T>(__t1).*__f)(_STD::forward<_Arg>(__arg)...);
}
// second bullet
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
!is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...), _T1&& __t1, _Arg&& ...__arg)
{
return ((*_STD::forward<_T1>(__t1)).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
!is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) const, _T1&& __t1, _Arg&& ...__arg)
{
return ((*_STD::forward<_T1>(__t1)).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
!is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) volatile, _T1&& __t1, _Arg&& ...__arg)
{
return ((*_STD::forward<_T1>(__t1)).*__f)(_STD::forward<_Arg>(__arg)...);
}
template <class _R, class _T, class _T1, class ..._Param, class ..._Arg>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
sizeof...(_Param) == sizeof...(_Arg) &&
!is_base_of<_T, typename remove_reference<_T1>::type>::value,
_R
>::type
__invoke(_R (_T::*__f)(_Param...) const volatile, _T1&& __t1, _Arg&& ...__arg)
{
return ((*_STD::forward<_T1>(__t1)).*__f)(_STD::forward<_Arg>(__arg)...);
}
// third bullet
template <class _R, class _T, class _T1>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_base_of<_T, typename remove_reference<_T1>::type>::value,
typename __apply_cv<_T1, _R>::type&&
>::type
__invoke(_R _T::* __f, _T1&& __t1)
{
return _STD::forward<_T1>(__t1).*__f;
}
// forth bullet
template <class _T1, class _R, bool>
struct __4th_helper
{
};
template <class _T1, class _R>
struct __4th_helper<_T1, _R, true>
{
typedef typename __apply_cv<decltype(*_STD::declval<_T1>()), _R>::type type;
};
template <class _R, class _T, class _T1>
inline _LIBCPP_INLINE_VISIBILITY
typename __4th_helper<_T1, _R,
!is_base_of<_T,
typename remove_reference<_T1>::type
>::value
>::type&&
__invoke(_R _T::* __f, _T1&& __t1)
{
return (*_STD::forward<_T1>(__t1)).*__f;
}
// fifth bullet
template <class _F, class ..._T>
inline _LIBCPP_INLINE_VISIBILITY
typename result_of<_F(_T...)>::type
__invoke(_F&& __f, _T&& ...__t)
{
return _STD::forward<_F>(__f)(_STD::forward<_T>(__t)...);
}
template <class _Tp, class ..._Args>
struct __invoke_return
{
typedef decltype(__invoke(_STD::declval<_Tp>(), _STD::declval<_Args>()...)) type;
};
template <class _Tp>
class reference_wrapper
: public __weak_result_type<_Tp>
{
public:
// types
typedef _Tp type;
private:
type* __f_;
public:
// construct/copy/destroy
_LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) : __f_(&__f) {}
#ifdef _LIBCPP_MOVE
private: reference_wrapper(type&&); public: // = delete; // do not bind to temps
#endif
// access
_LIBCPP_INLINE_VISIBILITY operator type& () const {return *__f_;}
_LIBCPP_INLINE_VISIBILITY type& get() const {return *__f_;}
// invoke
template <class... _ArgTypes>
typename __invoke_return<type&, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const
{
return __invoke(get(), _STD::forward<_ArgTypes>(__args)...);
}
};
template <class _Tp> struct ____is_reference_wrapper : public false_type {};
template <class _Tp> struct ____is_reference_wrapper<reference_wrapper<_Tp> > : public true_type {};
template <class _Tp> struct __is_reference_wrapper
: public ____is_reference_wrapper<typename remove_cv<_Tp>::type> {};
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<_Tp>
ref(_Tp& __t)
{
return reference_wrapper<_Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t)
{
return ref(__t.get());
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<const _Tp>
cref(const _Tp& __t)
{
return reference_wrapper<const _Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
reference_wrapper<const _Tp>
cref(reference_wrapper<_Tp> __t)
{
return cref(__t.get());
}
#ifdef _LIBCPP_MOVE
template <class _Tp> void ref(const _Tp&& __t);// = delete; // LWG 688
template <class _Tp> void cref(const _Tp&& __t);// = delete; // LWG 688
#endif
#endif // _LIBCPP_HAS_NO_VARIADICS
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_FUNCTIONAL_BASE

File diff suppressed because it is too large Load Diff

1761
libcxx/include/__hash_table Normal file

File diff suppressed because it is too large Load Diff

1433
libcxx/include/__locale Normal file

File diff suppressed because it is too large Load Diff

385
libcxx/include/__mutex_base Normal file
View File

@ -0,0 +1,385 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___MUTEX_BASE
#define _LIBCPP___MUTEX_BASE
#include <__config>
#include <chrono>
#include <system_error>
#include <pthread.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
class mutex
{
pthread_mutex_t __m_;
public:
mutex() {__m_ = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;}
~mutex();
private:
mutex(const mutex&);// = delete;
mutex& operator=(const mutex&);// = delete;
public:
void lock();
bool try_lock();
void unlock();
typedef pthread_mutex_t* native_handle_type;
native_handle_type native_handle() {return &__m_;}
};
struct defer_lock_t {};
struct try_to_lock_t {};
struct adopt_lock_t {};
//constexpr
extern const
defer_lock_t defer_lock;
//constexpr
extern const
try_to_lock_t try_to_lock;
//constexpr
extern const
adopt_lock_t adopt_lock;
template <class _Mutex>
class lock_guard
{
public:
typedef _Mutex mutex_type;
private:
mutex_type& __m_;
public:
explicit lock_guard(mutex_type& __m)
: __m_(__m) {__m_.lock();}
lock_guard(mutex_type& __m, adopt_lock_t)
: __m_(__m) {}
~lock_guard() {__m_.unlock();}
private:
lock_guard(lock_guard const&);// = delete;
lock_guard& operator=(lock_guard const&);// = delete;
};
template <class _Mutex>
class unique_lock
{
public:
typedef _Mutex mutex_type;
private:
mutex_type* __m_;
bool __owns_;
public:
unique_lock() : __m_(nullptr), __owns_(false) {}
explicit unique_lock(mutex_type& __m)
: __m_(&__m), __owns_(true) {__m_->lock();}
unique_lock(mutex_type& __m, defer_lock_t)
: __m_(&__m), __owns_(false) {}
unique_lock(mutex_type& __m, try_to_lock_t)
: __m_(&__m), __owns_(__m.try_lock()) {}
unique_lock(mutex_type& __m, adopt_lock_t)
: __m_(&__m), __owns_(true) {}
template <class _Clock, class _Duration>
unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
: __m_(&__m), __owns_(__m.try_lock_until(__t)) {}
template <class _Rep, class _Period>
unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
: __m_(&__m), __owns_(__m.try_lock_for(__d)) {}
~unique_lock()
{
if (__owns_)
__m_->unlock();
}
private:
unique_lock(unique_lock const&); // = delete;
unique_lock& operator=(unique_lock const&); // = delete;
public:
#ifdef _LIBCPP_MOVE
unique_lock(unique_lock&& __u)
: __m_(__u.__m_), __owns_(__u.__owns_)
{__u.__m_ = nullptr; __u.__owns_ = false;}
unique_lock& operator=(unique_lock&& __u)
{
if (__owns_)
__m_->unlock();
__m_ = __u.__m_;
__owns_ = __u.__owns_;
__u.__m_ = nullptr;
__u.__owns_ = false;
return *this;
}
#endif
void lock();
bool try_lock();
template <class _Rep, class _Period>
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
template <class _Clock, class _Duration>
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
void unlock();
void swap(unique_lock& __u)
{
_STD::swap(__m_, __u.__m_);
_STD::swap(__owns_, __u.__owns_);
}
mutex_type* release()
{
mutex_type* __m = __m_;
__m_ = nullptr;
__owns_ = false;
return __m;
}
bool owns_lock() const {return __owns_;}
// explicit
operator bool () const {return __owns_;}
mutex_type* mutex() const {return __m_;}
};
template <class _Mutex>
void
unique_lock<_Mutex>::lock()
{
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
if (__owns_)
__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
__m_->lock();
__owns_ = true;
}
template <class _Mutex>
bool
unique_lock<_Mutex>::try_lock()
{
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
if (__owns_)
__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
__owns_ = __m_->try_lock();
return __owns_;
}
template <class _Mutex>
template <class _Rep, class _Period>
bool
unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d)
{
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
if (__owns_)
__throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");
__owns_ = __m_->try_lock_for(__d);
return __owns_;
}
template <class _Mutex>
template <class _Clock, class _Duration>
bool
unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
{
if (__m_ == nullptr)
__throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
if (__owns_)
__throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");
__owns_ = __m_->try_lock_until(__t);
return __owns_;
}
template <class _Mutex>
void
unique_lock<_Mutex>::unlock()
{
if (!__owns_)
__throw_system_error(EPERM, "unique_lock::unlock: not locked");
__m_->unlock();
__owns_ = false;
}
template <class _Mutex>
inline
void
swap(unique_lock<_Mutex>& __x, unique_lock<_Mutex>& __y) {__x.swap(__y);}
struct cv_status
{
enum _ {
no_timeout,
timeout
};
_ __v_;
cv_status(_ __v) : __v_(__v) {}
operator int() const {return __v_;}
};
class condition_variable
{
pthread_cond_t __cv_;
public:
condition_variable() {__cv_ = (pthread_cond_t)PTHREAD_COND_INITIALIZER;}
~condition_variable();
private:
condition_variable(const condition_variable&); // = delete;
condition_variable& operator=(const condition_variable&); // = delete;
public:
void notify_one();
void notify_all();
void wait(unique_lock<mutex>& __lk);
template <class _Predicate>
void wait(unique_lock<mutex>& __lk, _Predicate __pred);
template <class _Duration>
cv_status
wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<chrono::system_clock, _Duration>& __t);
template <class _Clock, class _Duration>
cv_status
wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<_Clock, _Duration>& __t);
template <class _Clock, class _Duration, class _Predicate>
bool
wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred);
template <class _Rep, class _Period>
cv_status
wait_for(unique_lock<mutex>& __lk,
const chrono::duration<_Rep, _Period>& __d);
template <class _Rep, class _Period, class _Predicate>
bool
wait_for(unique_lock<mutex>& __lk,
const chrono::duration<_Rep, _Period>& __d,
_Predicate __pred);
typedef pthread_cond_t* native_handle_type;
native_handle_type native_handle() {return &__cv_;}
private:
void __do_timed_wait(unique_lock<mutex>& __lk,
chrono::time_point<chrono::system_clock, chrono::nanoseconds>);
};
template <class _To, class _Rep, class _Period>
inline
typename enable_if
<
chrono::__is_duration<_To>::value,
_To
>::type
__ceil(chrono::duration<_Rep, _Period> __d)
{
using namespace chrono;
_To __r = duration_cast<_To>(__d);
if (__r < __d)
++__r;
return __r;
}
template <class _Predicate>
void
condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred)
{
while (!__pred())
wait(__lk);
}
template <class _Duration>
cv_status
condition_variable::wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<chrono::system_clock, _Duration>& __t)
{
using namespace chrono;
typedef time_point<system_clock, nanoseconds> __nano_sys_tmpt;
__do_timed_wait(__lk,
__nano_sys_tmpt(__ceil<nanoseconds>(__t.time_since_epoch())));
return system_clock::now() < __t ? cv_status::no_timeout :
cv_status::timeout;
}
template <class _Clock, class _Duration>
cv_status
condition_variable::wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<_Clock, _Duration>& __t)
{
using namespace chrono;
system_clock::time_point __s_now = system_clock::now();
typename _Clock::time_point __c_now = _Clock::now();
__do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__t - __c_now));
return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
}
template <class _Clock, class _Duration, class _Predicate>
bool
condition_variable::wait_until(unique_lock<mutex>& __lk,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred)
{
while (!__pred())
{
if (wait_until(__lk, __t) == cv_status::timeout)
return __pred();
}
return true;
}
template <class _Rep, class _Period>
cv_status
condition_variable::wait_for(unique_lock<mutex>& __lk,
const chrono::duration<_Rep, _Period>& __d)
{
using namespace chrono;
system_clock::time_point __s_now = system_clock::now();
monotonic_clock::time_point __c_now = monotonic_clock::now();
__do_timed_wait(__lk, __s_now + __ceil<nanoseconds>(__d));
return monotonic_clock::now() - __c_now < __d ? cv_status::no_timeout :
cv_status::timeout;
}
template <class _Rep, class _Period, class _Predicate>
inline
bool
condition_variable::wait_for(unique_lock<mutex>& __lk,
const chrono::duration<_Rep, _Period>& __d,
_Predicate __pred)
{
return wait_until(__lk, chrono::monotonic_clock::now() + __d,
_STD::move(__pred));
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___MUTEX_BASE

View File

@ -0,0 +1,646 @@
// -*- C++ -*-
#ifndef _LIBCPP_SPLIT_BUFFER
#define _LIBCPP_SPLIT_BUFFER
#include <__config>
#include <type_traits>
#include <algorithm>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <bool>
class __split_buffer_common
{
protected:
void __throw_length_error() const;
void __throw_out_of_range() const;
};
template <class _Tp, class _Allocator>
struct __split_buffer
: private __split_buffer_common<true>
{
private:
__split_buffer(const __split_buffer&);
__split_buffer& operator=(const __split_buffer&);
public:
typedef _Tp value_type;
typedef _Allocator allocator_type;
typedef typename remove_reference<allocator_type>::type __alloc_rr;
typedef allocator_traits<__alloc_rr> __alloc_traits;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename __alloc_traits::size_type size_type;
typedef typename __alloc_traits::difference_type difference_type;
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
typedef pointer iterator;
typedef const_pointer const_iterator;
pointer __first_;
pointer __begin_;
pointer __end_;
__compressed_pair<pointer, allocator_type> __end_cap_;
typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
_LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() {return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const {return __end_cap_.second();}
_LIBCPP_INLINE_VISIBILITY pointer& __end_cap() {return __end_cap_.first();}
_LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const {return __end_cap_.first();}
__split_buffer();
explicit __split_buffer(__alloc_rr& __a);
explicit __split_buffer(const __alloc_rr& __a);
__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
~__split_buffer();
#ifdef _LIBCPP_MOVE
__split_buffer(__split_buffer&& __c);
__split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
__split_buffer& operator=(__split_buffer&& __c);
#endif
_LIBCPP_INLINE_VISIBILITY iterator begin() {return __begin_;}
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return __begin_;}
_LIBCPP_INLINE_VISIBILITY iterator end() {return __end_;}
_LIBCPP_INLINE_VISIBILITY const_iterator end() const {return __end_;}
_LIBCPP_INLINE_VISIBILITY void clear() {__destruct_at_end(__begin_);}
_LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
_LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;}
_LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
_LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
_LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
_LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;}
_LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
_LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);}
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);}
void reserve(size_type __n);
void shrink_to_fit();
void push_front(const_reference __x);
void push_back(const_reference __x);
#ifdef _LIBCPP_MOVE
void push_front(value_type&& __x);
void push_back(value_type&& __x);
template <class... _Args>
void emplace_back(_Args&&... __args);
#endif
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
void __construct_at_end(size_type __n);
void __construct_at_end(size_type __n, false_type);
void __construct_at_end(size_type __n, true_type);
void __construct_at_end(size_type __n, const_reference __x);
void __construct_at_end(size_type __n, const_reference __x, false_type);
void __construct_at_end(size_type __n, const_reference __x, true_type);
template <class _InputIter>
typename enable_if
<
__is_input_iterator<_InputIter>::value &&
!__is_forward_iterator<_InputIter>::value,
void
>::type
__construct_at_end(_InputIter __first, _InputIter __last);
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
__construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
_LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
{__destruct_at_begin(__new_begin, has_trivial_destructor<value_type>());}
void __destruct_at_begin(pointer __new_begin, false_type);
void __destruct_at_begin(pointer __new_begin, true_type);
_LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last)
{__destruct_at_end(__new_last, has_trivial_destructor<value_type>());}
void __destruct_at_end(pointer __new_last, false_type);
void __destruct_at_end(pointer __new_last, true_type);
void swap(__split_buffer& __x);
bool __invariants() const;
private:
void __move_assign_alloc(const __split_buffer& __c, true_type)
{
__alloc() = _STD::move(__c.__alloc());
}
void __move_assign_alloc(const __split_buffer& __c, false_type)
{}
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y)
{__swap_alloc(__x, __y, integral_constant<bool,
__alloc_traits::propagate_on_container_swap::value>());}
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, true_type)
{
using _STD::swap;
swap(__x, __y);
}
static void __swap_alloc(__alloc_rr& __x, __alloc_rr& __y, false_type)
{}
};
template <class _Tp, class _Allocator>
bool
__split_buffer<_Tp, _Allocator>::__invariants() const
{
if (__first_ == nullptr)
{
if (__begin_ != nullptr)
return false;
if (__end_ != nullptr)
return false;
if (__end_cap() != nullptr)
return false;
}
else
{
if (__begin_ < __first_)
return false;
if (__end_ < __begin_)
return false;
if (__end_cap() < __end_)
return false;
}
return true;
}
// Default constructs __n objects starting at __end_
// throws if construction throws
// Precondition: __n > 0
// Precondition: size() + __n <= capacity()
// Postcondition: size() == size() + __n
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
__construct_at_end(__n, __is_zero_default_constructible<value_type>());
}
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, false_type)
{
__alloc_rr& __a = this->__alloc();
do
{
__alloc_traits::construct(__a, _STD::__to_raw_pointer(this->__end_), value_type());
++this->__end_;
--__n;
} while (__n > 0);
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, true_type)
{
_STD::memset(this->__end_, 0, __n*sizeof(value_type));
this->__end_ += __n;
}
// Copy constructs __n objects starting at __end_ from __x
// throws if construction throws
// Precondition: __n > 0
// Precondition: size() + __n <= capacity()
// Postcondition: size() == old size() + __n
// Postcondition: [i] == __x for all i in [size() - __n, __n)
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
__construct_at_end(__n, __x, integral_constant<bool, has_trivial_copy_constructor<value_type>::value &&
has_trivial_copy_assign<value_type>::value>());
}
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x, false_type)
{
__alloc_rr& __a = this->__alloc();
do
{
__alloc_traits::construct(__a, _STD::__to_raw_pointer(this->__end_), __x);
++this->__end_;
--__n;
} while (__n > 0);
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x, true_type)
{
_STD::fill_n(this->__end_, __n, __x);
this->__end_ += __n;
}
template <class _Tp, class _Allocator>
template <class _InputIter>
typename enable_if
<
__is_input_iterator<_InputIter>::value &&
!__is_forward_iterator<_InputIter>::value,
void
>::type
__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
{
__alloc_rr& __a = this->__alloc();
for (; __first != __last; ++__first)
{
if (__end_ == __end_cap())
{
size_type __old_cap = __end_cap() - __first_;
size_type __new_cap = _STD::max<size_type>(2 * __old_cap, 8);
__split_buffer __buf(__new_cap, 0, __a);
for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_)
__alloc_traits::construct(__buf.__alloc(),
_STD::__to_raw_pointer(__buf.__end_), _STD::move(*__p));
swap(__buf);
}
__alloc_traits::construct(__a, _STD::__to_raw_pointer(this->__end_), *__first);
++this->__end_;
}
}
template <class _Tp, class _Allocator>
template <class _ForwardIterator>
typename enable_if
<
__is_forward_iterator<_ForwardIterator>::value,
void
>::type
__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
{
__alloc_rr& __a = this->__alloc();
for (; __first != __last; ++__first)
{
__alloc_traits::construct(__a, _STD::__to_raw_pointer(this->__end_), *__first);
++this->__end_;
}
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
{
while (__begin_ < __new_begin)
__alloc_traits::destroy(__alloc(), __begin_++);
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
{
__begin_ = __new_begin;
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type)
{
while (__new_last < __end_)
__alloc_traits::destroy(__alloc(), --__end_);
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type)
{
__end_ = __new_last;
}
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
: __end_cap_(0, __a)
{
__first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr;
__begin_ = __end_ = __first_ + __start;
__end_cap() = __first_ + __cap;
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer()
: __first_(0), __begin_(0), __end_(0), __end_cap_(0)
{
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
: __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
{
}
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
__split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
: __first_(0), __begin_(0), __end_(0), __end_cap_(0, __a)
{
}
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::~__split_buffer()
{
clear();
if (__first_)
__alloc_traits::deallocate(__alloc(), __first_, capacity());
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
: __first_(_STD::move(__c.__first_)),
__begin_(_STD::move(__c.__begin_)),
__end_(_STD::move(__c.__end_)),
__end_cap_(_STD::move(__c.__end_cap_))
{
__c.__first_ = nullptr;
__c.__begin_ = nullptr;
__c.__end_ = nullptr;
__c.__end_cap() = nullptr;
}
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
: __end_cap_(__a)
{
if (__a == __c.__alloc())
{
__first_ = __c.__first_;
__begin_ = __c.__begin_;
__end_ = __c.__end_;
__end_cap() = __c.__end_cap();
__c.__first_ = nullptr;
__c.__begin_ = nullptr;
__c.__end_ = nullptr;
__c.__end_cap() = nullptr;
}
else
{
size_type __cap = __c.size();
__first_ = __alloc_traits::allocate(__alloc(), __cap);
__begin_ = __end_ = __first_;
__end_cap() = __first_ + __cap;
typedef move_iterator<iterator> _I;
__construct_at_end(_I(__c.begin()), _I(__c.end()));
}
}
template <class _Tp, class _Allocator>
__split_buffer<_Tp, _Allocator>&
__split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
{
clear();
shrink_to_fit();
__first_ = __c.__first_;
__begin_ = __c.__begin_;
__end_ = __c.__end_;
__end_cap() = __c.__end_cap();
__move_assign_alloc(__c,
integral_constant<bool,
__alloc_traits::propagate_on_container_move_assignment::value>());
__c.__first_ = __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr;
return *this;
}
#endif
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
{
_STD::swap(__first_, __x.__first_);
_STD::swap(__begin_, __x.__begin_);
_STD::swap(__end_, __x.__end_);
_STD::swap(__end_cap(), __x.__end_cap());
__swap_alloc(__alloc(), __x.__alloc());
}
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::reserve(size_type __n)
{
if (__n < capacity())
{
__split_buffer<value_type, __alloc_rr&> __t(__n, 0, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::shrink_to_fit()
{
if (capacity() > size())
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
__split_buffer<value_type, __alloc_rr&> __t(size(), 0, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
__t.__end_ = __t.__begin_ + (__end_ - __begin_);
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
}
#endif
}
}
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
{
if (__begin_ == __first_)
{
if (__end_ < __end_cap())
{
difference_type __d = __end_cap() - __end_;
__d = (__d + 1) / 2;
__begin_ = _STD::move_backward(__begin_, __end_, __end_ + __d);
__end_ += __d;
}
else
{
size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1);
__split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 2) / 4, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
__alloc_traits::construct(__alloc(), _STD::__to_raw_pointer(__begin_-1), __x);
--__begin_;
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
{
if (__begin_ == __first_)
{
if (__end_ < __end_cap())
{
difference_type __d = __end_cap() - __end_;
__d = (__d + 1) / 2;
__begin_ = _STD::move_backward(__begin_, __end_, __end_ + __d);
__end_ += __d;
}
else
{
size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1);
__split_buffer<value_type, __alloc_rr&> __t(__c, (__c + 2) / 4, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
__alloc_traits::construct(__alloc(), _STD::__to_raw_pointer(__begin_-1),
_STD::move(__x));
--__begin_;
}
#endif
template <class _Tp, class _Allocator>
_LIBCPP_INLINE_VISIBILITY inline
void
__split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
{
if (__end_ == __end_cap())
{
if (__begin_ > __first_)
{
difference_type __d = __begin_ - __first_;
__d = (__d + 1) / 2;
__end_ = _STD::move(__begin_, __end_, __begin_ - __d);
__begin_ -= __d;
}
else
{
size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1);
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
__alloc_traits::construct(__alloc(), _STD::__to_raw_pointer(__end_), __x);
++__end_;
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Allocator>
void
__split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
{
if (__end_ == __end_cap())
{
if (__begin_ > __first_)
{
difference_type __d = __begin_ - __first_;
__d = (__d + 1) / 2;
__end_ = _STD::move(__begin_, __end_, __begin_ - __d);
__begin_ -= __d;
}
else
{
size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1);
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
__alloc_traits::construct(__alloc(), _STD::__to_raw_pointer(__end_),
_STD::move(__x));
++__end_;
}
template <class _Tp, class _Allocator>
template <class... _Args>
void
__split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
{
if (__end_ == __end_cap())
{
if (__begin_ > __first_)
{
difference_type __d = __begin_ - __first_;
__d = (__d + 1) / 2;
__end_ = _STD::move(__begin_, __end_, __begin_ - __d);
__begin_ -= __d;
}
else
{
size_type __c = max<size_type>(2 * (__end_cap() - __first_), 1);
__split_buffer<value_type, __alloc_rr&> __t(__c, __c / 4, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_),
move_iterator<pointer>(__end_));
_STD::swap(__first_, __t.__first_);
_STD::swap(__begin_, __t.__begin_);
_STD::swap(__end_, __t.__end_);
_STD::swap(__end_cap(), __t.__end_cap());
}
}
__alloc_traits::construct(__alloc(), _STD::__to_raw_pointer(__end_),
_STD::forward<_Args>(__args)...);
++__end_;
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_SPLIT_BUFFER
// hh 080222 Created

View File

@ -0,0 +1,73 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___SSO_ALLOCATOR
#define _LIBCPP___SSO_ALLOCATOR
#include <__config>
#include <type_traits>
#include <new>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, size_t _N> class _LIBCPP_HIDDEN __sso_allocator;
template <size_t _N>
class _LIBCPP_HIDDEN __sso_allocator<void, _N>
{
public:
typedef const void* const_pointer;
typedef void value_type;
};
template <class _Tp, size_t _N>
class _LIBCPP_HIDDEN __sso_allocator
{
typename aligned_storage<sizeof(_Tp) * _N>::type buf_;
bool __allocated_;
public:
typedef size_t size_type;
typedef _Tp* pointer;
typedef _Tp value_type;
_LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
_LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _N>&) throw()
: __allocated_(false) {}
private:
__sso_allocator& operator=(const __sso_allocator&);
public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, typename __sso_allocator<void, _N>::const_pointer = 0)
{
if (!__allocated_ && __n <= _N)
{
__allocated_ = true;
return (pointer)&buf_;
}
return static_cast<pointer>(::operator new(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type)
{
if (__p == (pointer)&buf_)
__allocated_ = false;
else
::operator delete(__p);
}
_LIBCPP_INLINE_VISIBILITY size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
bool operator==(__sso_allocator& __a) const {return &buf_ == &__a.buf_;}
bool operator!=(__sso_allocator& __a) const {return &buf_ != &__a.buf_;}
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___SSO_ALLOCATOR

313
libcxx/include/__std_stream Normal file
View File

@ -0,0 +1,313 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___STD_STREAM
#define _LIBCPP___STD_STREAM
#include <__config>
#include <ostream>
#include <istream>
#include <__locale>
#include <cstdio>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
static const unsigned __limit = 8;
// __stdinbuf
template <class _CharT>
class _LIBCPP_HIDDEN __stdinbuf
: public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
typedef _CharT char_type;
typedef char_traits<char_type> traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef typename traits_type::state_type state_type;
explicit __stdinbuf(FILE* __fp);
protected:
virtual int_type underflow();
virtual int_type uflow();
virtual int_type pbackfail(int_type __c = traits_type::eof());
virtual void imbue(const locale& __loc);
private:
FILE* __file_;
const codecvt<char_type, char, state_type>* __cv_;
state_type __st_;
int __encoding_;
bool __always_noconv_;
__stdinbuf(const __stdinbuf&);
__stdinbuf& operator=(const __stdinbuf&);
int_type __getchar(bool __consume);
};
template <class _CharT>
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp)
: __file_(__fp),
__st_()
{
imbue(this->getloc());
}
template <class _CharT>
void
__stdinbuf<_CharT>::imbue(const locale& __loc)
{
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
__encoding_ = __cv_->encoding();
__always_noconv_ = __cv_->always_noconv();
if (__encoding_ > __limit)
__throw_runtime_error("unsupported locale for standard input");
}
template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::underflow()
{
return __getchar(false);
}
template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::uflow()
{
return __getchar(true);
}
template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::__getchar(bool __consume)
{
char __extbuf[__limit];
int __nread = max(1, __encoding_);
for (int __i = 0; __i < __nread; ++__i)
{
char __c = getc(__file_);
if (__c == EOF)
return traits_type::eof();
__extbuf[__i] = static_cast<char>(__c);
}
char_type __1buf;
if (__always_noconv_)
__1buf = static_cast<char_type>(__extbuf[0]);
else
{
const char* __enxt;
char_type* __inxt;
codecvt_base::result __r;
do
{
state_type __sv_st = __st_;
__r = __cv_->in(__st_, __extbuf, __extbuf + __nread, __enxt,
&__1buf, &__1buf + 1, __inxt);
switch (__r)
{
case _STD::codecvt_base::ok:
break;
case codecvt_base::partial:
__st_ = __sv_st;
if (__nread == sizeof(__extbuf))
return traits_type::eof();
{
char __c = getc(__file_);
if (__c == EOF)
return traits_type::eof();
__extbuf[__nread] = static_cast<char>(__c);
}
++__nread;
break;
case codecvt_base::error:
return traits_type::eof();
case _STD::codecvt_base::noconv:
__1buf = static_cast<char_type>(__extbuf[0]);
break;
}
} while (__r == _STD::codecvt_base::partial);
}
if (!__consume)
{
for (int __i = __nread; __i > 0;)
{
if (ungetc(__extbuf[--__i], __file_) == EOF)
return traits_type::eof();
}
}
return traits_type::to_int_type(__1buf);
}
template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::pbackfail(int_type __c)
{
if (traits_type::eq_int_type(__c, traits_type::eof()))
return __c;
char __extbuf[__limit];
char* __enxt;
const char_type __ci = traits_type::to_char_type(__c);
const char_type* __inxt;
switch (__cv_->out(__st_, &__ci, &__ci + 1, __inxt,
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
{
case _STD::codecvt_base::ok:
break;
case _STD::codecvt_base::noconv:
__extbuf[0] = static_cast<char>(__c);
__enxt = __extbuf + 1;
break;
case codecvt_base::partial:
case codecvt_base::error:
return traits_type::eof();
}
while (__enxt > __extbuf)
if (ungetc(*--__enxt, __file_) == EOF)
return traits_type::eof();
return traits_type::not_eof(__c);
}
// __stdoutbuf
template <class _CharT>
class _LIBCPP_HIDDEN __stdoutbuf
: public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
typedef _CharT char_type;
typedef char_traits<char_type> traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef typename traits_type::state_type state_type;
explicit __stdoutbuf(FILE* __fp);
protected:
virtual int_type overflow (int_type __c = traits_type::eof());
virtual int sync();
virtual void imbue(const locale& __loc);
private:
FILE* __file_;
const codecvt<char_type, char, state_type>* __cv_;
state_type __st_;
bool __always_noconv_;
__stdoutbuf(const __stdoutbuf&);
__stdoutbuf& operator=(const __stdoutbuf&);
};
template <class _CharT>
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp)
: __file_(__fp),
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
__st_(),
__always_noconv_(__cv_->always_noconv())
{
}
template <class _CharT>
typename __stdoutbuf<_CharT>::int_type
__stdoutbuf<_CharT>::overflow(int_type __c)
{
char __extbuf[__limit];
char_type __1buf;
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
this->setp(&__1buf, &__1buf+1);
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
if (__always_noconv_)
{
if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
return traits_type::eof();
}
else
{
char* __extbe = __extbuf;
codecvt_base::result __r;
do
{
const char_type* __e;
__r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
__extbuf,
__extbuf + sizeof(__extbuf),
__extbe);
if (__e == this->pbase())
return traits_type::eof();
if (__r == codecvt_base::noconv)
{
if (fwrite(this->pbase(), 1, 1, __file_) != 1)
return traits_type::eof();
}
else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
{
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
return traits_type::eof();
if (__r == codecvt_base::partial)
{
this->setp((char_type*)__e, this->pptr());
this->pbump(this->epptr() - this->pbase());
}
}
else
return traits_type::eof();
} while (__r == codecvt_base::partial);
}
this->setp(0, 0);
}
return traits_type::not_eof(__c);
}
template <class _CharT>
int
__stdoutbuf<_CharT>::sync()
{
char __extbuf[__limit];
codecvt_base::result __r;
do
{
char* __extbe;
__r = __cv_->unshift(__st_, __extbuf,
__extbuf + sizeof(__extbuf),
__extbe);
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
return -1;
} while (__r == codecvt_base::partial);
if (__r == codecvt_base::error)
return -1;
if (fflush(__file_))
return -1;
return 0;
}
template <class _CharT>
void
__stdoutbuf<_CharT>::imbue(const locale& __loc)
{
sync();
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
__always_noconv_ = __cv_->always_noconv();
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___STD_STREAM

2170
libcxx/include/__tree Normal file

File diff suppressed because it is too large Load Diff

229
libcxx/include/__tuple Normal file
View File

@ -0,0 +1,229 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___TUPLE
#define _LIBCPP___TUPLE
#include <__config>
#include <cstddef>
#include <type_traits>
#pragma GCC system_header
#ifdef _LIBCPP_HAS_NO_VARIADICS
#include <__tuple_03>
#else
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class tuple_size;
template <size_t _Ip, class _Tp> class tuple_element;
template <class ..._Tp> class tuple;
template <class _T1, class _T2> class pair;
template <class _Tp, size_t _Size> struct array;
template <class _Tp> struct __tuple_like : false_type {};
template <class... _Tp> struct __tuple_like<tuple<_Tp...>> : true_type {};
template <class... _Tp> struct __tuple_like<const tuple<_Tp...>> : true_type {};
template <class _T1, class _T2> struct __tuple_like<pair<_T1, _T2> > : true_type {};
template <class _T1, class _T2> struct __tuple_like<const pair<_T1, _T2> > : true_type {};
template <class _Tp, size_t _Size> struct __tuple_like<array<_Tp, _Size> > : true_type {};
template <class _Tp, size_t _Size> struct __tuple_like<const array<_Tp, _Size> > : true_type {};
template <size_t _Ip, class ..._Tp>
typename tuple_element<_Ip, tuple<_Tp...>>::type&
get(tuple<_Tp...>&);
template <size_t _Ip, class ..._Tp>
const typename tuple_element<_Ip, tuple<_Tp...>>::type&
get(const tuple<_Tp...>&);
template <size_t _Ip, class _T1, class _T2>
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>&);
template <size_t _Ip, class _T1, class _T2>
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>&);
template <size_t _Ip, class _Tp, size_t _Size>
_Tp&
get(array<_Tp, _Size>&);
template <size_t _Ip, class _Tp, size_t _Size>
const _Tp&
get(const array<_Tp, _Size>&);
// __make_tuple_indices
template <size_t...> struct __tuple_indices {};
template <size_t _Sp, class _IntTuple, size_t _Ep>
struct __make_indices_imp;
template <size_t _Sp, size_t ..._Indices, size_t _Ep>
struct __make_indices_imp<_Sp, __tuple_indices<_Indices...>, _Ep>
{
typedef typename __make_indices_imp<_Sp+1, __tuple_indices<_Indices..., _Sp>, _Ep>::type type;
};
template <size_t _Ep, size_t ..._Indices>
struct __make_indices_imp<_Ep, __tuple_indices<_Indices...>, _Ep>
{
typedef __tuple_indices<_Indices...> type;
};
template <size_t _Ep, size_t _Sp = 0>
struct __make_tuple_indices
{
static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
typedef typename __make_indices_imp<_Sp, __tuple_indices<>, _Ep>::type type;
};
// __tuple_types
template <class ..._Tp> struct __tuple_types {};
template <size_t _Ip>
class tuple_element<_Ip, __tuple_types<>>
{
public:
static_assert(_Ip == 0, "tuple_element index out of range");
static_assert(_Ip != 0, "tuple_element index out of range");
};
template <class _Hp, class ..._Tp>
class tuple_element<0, __tuple_types<_Hp, _Tp...>>
{
public:
typedef _Hp type;
};
template <size_t _Ip, class _Hp, class ..._Tp>
class tuple_element<_Ip, __tuple_types<_Hp, _Tp...>>
{
public:
typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...>>::type type;
};
template <class ..._Tp>
class tuple_size<__tuple_types<_Tp...>>
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <class... _Tp> struct __tuple_like<__tuple_types<_Tp...>> : true_type {};
// __make_tuple_types
template <class _TupleTypes, class _Tp, size_t _Sp, size_t _Ep>
struct __make_tuple_types_imp;
template <class ..._Types, class _Tp, size_t _Sp, size_t _Ep>
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Sp, _Ep>
{
typedef typename remove_reference<_Tp>::type _Tpr;
typedef typename __make_tuple_types_imp<__tuple_types<_Types...,
typename conditional<is_reference<_Tp>::value,
typename tuple_element<_Sp, _Tpr>::type&,
typename tuple_element<_Sp, _Tpr>::type>::type>,
_Tp, _Sp+1, _Ep>::type type;
};
template <class ..._Types, class _Tp, size_t _Ep>
struct __make_tuple_types_imp<__tuple_types<_Types...>, _Tp, _Ep, _Ep>
{
typedef __tuple_types<_Types...> type;
};
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, size_t _Sp = 0>
struct __make_tuple_types
{
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
typedef typename __make_tuple_types_imp<__tuple_types<>, _Tp, _Sp, _Ep>::type type;
};
// __make_assignable_types
template <class _Tuple, class _Tp, size_t _Sp, size_t _Ep>
struct __make_assignable_types_imp;
template <class ..._Types, class _Tp, size_t _Sp, size_t _Ep>
struct __make_assignable_types_imp<__tuple_types<_Types...>, _Tp, _Sp, _Ep>
{
typedef typename __make_assignable_types_imp<__tuple_types<_Types...,
typename remove_reference<typename tuple_element<_Sp, _Tp>::type>::type>,
_Tp, _Sp+1, _Ep>::type type;
};
template <class ..._Types, class _Tp, size_t _Ep>
struct __make_assignable_types_imp<__tuple_types<_Types...>, _Tp, _Ep, _Ep>
{
typedef __tuple_types<_Types...> type;
};
template <class _Tp, size_t _Ep = tuple_size<typename remove_reference<_Tp>::type>::value, size_t _Sp = 0>
struct __make_assignable_types
{
static_assert(_Sp <= _Ep, "__make_assignable_types input error");
typedef typename __make_assignable_types_imp<__tuple_types<>, typename remove_reference<_Tp>::type, _Sp, _Ep>::type type;
};
// __tuple_convertible
template <bool, class _Tp, class _Up>
struct __tuple_convertible_imp : public false_type {};
template <class _Tp0, class ..._Tp, class _Up0, class ..._Up>
struct __tuple_convertible_imp<true, __tuple_types<_Tp0, _Tp...>, __tuple_types<_Up0, _Up...>>
: public integral_constant<bool,
is_convertible<_Tp0, _Up0>::value &&
__tuple_convertible_imp<true, __tuple_types<_Tp...>, __tuple_types<_Up...>>::value> {};
template <>
struct __tuple_convertible_imp<true, __tuple_types<>, __tuple_types<>>
: public true_type {};
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value>
struct __tuple_convertible
: public false_type {};
template <class _Tp, class _Up>
struct __tuple_convertible<_Tp, _Up, true, true>
: public __tuple_convertible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
tuple_size<_Up>::value,
typename __make_tuple_types<_Tp>::type, typename __make_tuple_types<_Up>::type>
{};
// __tuple_assignable
template <class _Tp, class _Up, bool = __tuple_like<typename remove_reference<_Tp>::type>::value,
bool = __tuple_like<_Up>::value>
struct __tuple_assignable
: public false_type {};
template <class _Tp, class _Up>
struct __tuple_assignable<_Tp, _Up, true, true>
: public __tuple_convertible_imp<tuple_size<typename remove_reference<_Tp>::type>::value ==
tuple_size<_Up>::value,
typename __make_tuple_types<_Tp>::type, typename __make_assignable_types<_Up>::type>
{};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_HAS_NO_VARIADICS
#endif // _LIBCPP___TUPLE

25
libcxx/include/__tuple_03 Normal file
View File

@ -0,0 +1,25 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___TUPLE_03
#define _LIBCPP___TUPLE_03
#include <__config>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp> class tuple_size;
template <size_t _Ip, class _Tp> class tuple_element;
_LIBCPP_END_NAMESPACE_STD
#endif

5034
libcxx/include/algorithm Normal file

File diff suppressed because it is too large Load Diff

296
libcxx/include/array Normal file
View File

@ -0,0 +1,296 @@
// -*- C++ -*-
//===---------------------------- array -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_ARRAY
#define _LIBCPP_ARRAY
/*
array synopsis
namespace std
{
template <class T, size_t N >
struct array
{
// types:
typedef T & reference;
typedef const T & const_reference;
typedef implementation defined iterator;
typedef implementation defined const_iterator;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// No explicit construct/copy/destroy for aggregate type
void fill(const T& u);
void swap(array& a);
// iterators:
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
// capacity:
constexpr size_type size() const;
constexpr size_type max_size() const;
bool empty() const;
// element access:
reference operator[](size_type n);
const_reference operator[](size_type n) const;
const_reference at(size_type n) const;
reference at(size_type n);
reference front();
const_reference front() const;
reference back();
const_reference back() const;
T* data();
const T* data() const;
};
template <class T, size_t N>
bool operator==(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N>
bool operator!=(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N>
bool operator<(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N>
bool operator>(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N>
bool operator<=(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N>
bool operator>=(const array<T,N>& x, const array<T,N>& y);
template <class T, size_t N >
void swap(array<T,N>& x, array<T,N>& y);
template <class T> class tuple_size;
template <int I, class T> class tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <int I, class T, size_t N> struct tuple_element<I, array<T, N>>;
template <int I, class T, size_t N> T& get(array<T, N>&);
template <int I, class T, size_t N> const T& get(const array<T, N>&);
} // std
*/
#include <__config>
#include <__tuple>
#include <type_traits>
#include <utility>
#include <iterator>
#include <algorithm>
#include <stdexcept>
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, size_t _Size>
struct array
{
// types:
typedef array __self;
typedef _Tp value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
value_type __elems_[_Size > 0 ? _Size : 1];
// No explicit construct/copy/destroy for aggregate type
_LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) {_STD::fill_n(__elems_, _Size, __u);}
_LIBCPP_INLINE_VISIBILITY void swap(array& __a) {_STD::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_);}
// iterators:
_LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return const_iterator(__elems_);}
_LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY const_iterator end() const {return const_iterator(__elems_ + _Size);}
_LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() {return reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const {return const_reverse_iterator(end());}
_LIBCPP_INLINE_VISIBILITY reverse_iterator rend() {return reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const {return const_reverse_iterator(begin());}
_LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const {return begin();}
_LIBCPP_INLINE_VISIBILITY const_iterator cend() const {return end();}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const {return rbegin();}
_LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const {return rend();}
// capacity:
_LIBCPP_INLINE_VISIBILITY /*constexpr*/ size_type size() const {return _Size;}
_LIBCPP_INLINE_VISIBILITY /*constexpr*/ size_type max_size() const {return _Size;}
_LIBCPP_INLINE_VISIBILITY bool empty() const {return _Size == 0;}
// element access:
_LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __elems_[__n];}
_LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __elems_[__n];}
reference at(size_type __n);
const_reference at(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY reference front() {return __elems_[0];}
_LIBCPP_INLINE_VISIBILITY const_reference front() const {return __elems_[0];}
_LIBCPP_INLINE_VISIBILITY reference back() {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY const_reference back() const {return __elems_[_Size > 0 ? _Size-1 : 0];}
_LIBCPP_INLINE_VISIBILITY value_type* data() {return __elems_;}
_LIBCPP_INLINE_VISIBILITY const value_type* data() const {return __elems_;}
};
template <class _Tp, size_t _Size>
typename array<_Tp, _Size>::reference
array<_Tp, _Size>::at(size_type __n)
{
if (__n >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("array::at");
#else
assert(!"array::at out_of_range");
#endif
return __elems_[__n];
}
template <class _Tp, size_t _Size>
typename array<_Tp, _Size>::const_reference
array<_Tp, _Size>::at(size_type __n) const
{
if (__n >= _Size)
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("array::at");
#else
assert(!"array::at out_of_range");
#endif
return __elems_[__n];
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return _STD::equal(__x.__elems_, __x.__elems_ + _Size, __y.__elems_);
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return !(__x == __y);
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return _STD::lexicographical_compare(__x.__elems_, __x.__elems_ + _Size, __y.__elems_, __y.__elems_ + _Size);
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return __y < __x;
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return !(__y < __x);
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
bool
operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
return !(__x < __y);
}
template <class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
void
swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
{
__x.swap(__y);
}
template <class _Tp, size_t _Size>
class tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};
template <class _Tp, size_t _Size>
class tuple_size<const array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size>
class tuple_element<_Ip, array<_Tp, _Size> >
{
public:
typedef _Tp type;
};
template <size_t _Ip, class _Tp, size_t _Size>
class tuple_element<_Ip, const array<_Tp, _Size> >
{
public:
typedef const _Tp type;
};
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
_Tp&
get(array<_Tp, _Size>& __a)
{
return __a[_Ip];
}
template <size_t _Ip, class _Tp, size_t _Size>
_LIBCPP_INLINE_VISIBILITY inline
const _Tp&
get(const array<_Tp, _Size>& __a)
{
return __a[_Ip];
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_ARRAY

1022
libcxx/include/bitset Normal file

File diff suppressed because it is too large Load Diff

23
libcxx/include/cassert Normal file
View File

@ -0,0 +1,23 @@
// -*- C++ -*-
//===-------------------------- cassert -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/*
cassert synopsis
Macros:
assert
*/
#include <__config>
#include <assert.h>
#pragma GCC system_header

27
libcxx/include/ccomplex Normal file
View File

@ -0,0 +1,27 @@
// -*- C++ -*-
//===--------------------------- ccomplex ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CCOMPLEX
#define _LIBCPP_CCOMPLEX
/*
ccomplex synopsis
#include <complex>
*/
#include <complex>
#pragma GCC system_header
// hh 080623 Created
#endif // _LIBCPP_CCOMPLEX

159
libcxx/include/cctype Normal file
View File

@ -0,0 +1,159 @@
// -*- C++ -*-
//===---------------------------- cctype ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CCTYPE
#define _LIBCPP_CCTYPE
/*
cctype synopsis
namespace std
{
int isalnum(int c);
int isalpha(int c);
int isblank(int c); // C99
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);
} // std
*/
#include <__config>
#include <ctype.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
#ifdef isalnum
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalnum(int __c) {return isalnum(__c);}
#undef isalnum
inline _LIBCPP_INLINE_VISIBILITY int isalnum(int __c) {return __libcpp_isalnum(__c);}
#else // isalnum
using ::isalnum;
#endif // isalnum
#ifdef isalpha
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalpha(int __c) {return isalpha(__c);}
#undef isalpha
inline _LIBCPP_INLINE_VISIBILITY int isalpha(int __c) {return __libcpp_isalpha(__c);}
#else // isalpha
using ::isalpha;
#endif // isalpha
#ifdef isblank
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isblank(int __c) {return isblank(__c);}
#undef isblank
inline _LIBCPP_INLINE_VISIBILITY int isblank(int __c) {return __libcpp_isblank(__c);}
#else // isblank
using ::isblank;
#endif // isblank
#ifdef iscntrl
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iscntrl(int __c) {return iscntrl(__c);}
#undef iscntrl
inline _LIBCPP_INLINE_VISIBILITY int iscntrl(int __c) {return __libcpp_iscntrl(__c);}
#else // iscntrl
using ::iscntrl;
#endif // iscntrl
#ifdef isdigit
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isdigit(int __c) {return isdigit(__c);}
#undef isdigit
inline _LIBCPP_INLINE_VISIBILITY int isdigit(int __c) {return __libcpp_isdigit(__c);}
#else // isdigit
using ::isdigit;
#endif // isdigit
#ifdef isgraph
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isgraph(int __c) {return isgraph(__c);}
#undef isgraph
inline _LIBCPP_INLINE_VISIBILITY int isgraph(int __c) {return __libcpp_isgraph(__c);}
#else // isgraph
using ::isgraph;
#endif // isgraph
#ifdef islower
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_islower(int __c) {return islower(__c);}
#undef islower
inline _LIBCPP_INLINE_VISIBILITY int islower(int __c) {return __libcpp_islower(__c);}
#else // islower
using ::islower;
#endif // islower
#ifdef isprint
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isprint(int __c) {return isprint(__c);}
#undef isprint
inline _LIBCPP_INLINE_VISIBILITY int isprint(int __c) {return __libcpp_isprint(__c);}
#else // isprint
using ::isprint;
#endif // isprint
#ifdef ispunct
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ispunct(int __c) {return ispunct(__c);}
#undef ispunct
inline _LIBCPP_INLINE_VISIBILITY int ispunct(int __c) {return __libcpp_ispunct(__c);}
#else // ispunct
using ::ispunct;
#endif // ispunct
#ifdef isspace
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isspace(int __c) {return isspace(__c);}
#undef isspace
inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_isspace(__c);}
#else // isspace
using ::isspace;
#endif // isspace
#ifdef isupper
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isupper(int __c) {return isupper(__c);}
#undef isupper
inline _LIBCPP_INLINE_VISIBILITY int isupper(int __c) {return __libcpp_isupper(__c);}
#else // isupper
using ::isupper;
#endif // isupper
#ifdef isxdigit
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);}
#undef isxdigit
inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);}
#else // isxdigit
using ::isxdigit;
#endif // isxdigit
#ifdef tolower
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_tolower(int __c) {return tolower(__c);}
#undef tolower
inline _LIBCPP_INLINE_VISIBILITY int tolower(int __c) {return __libcpp_tolower(__c);}
#else // tolower
using ::tolower;
#endif // tolower
#ifdef toupper
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_toupper(int __c) {return toupper(__c);}
#undef toupper
inline _LIBCPP_INLINE_VISIBILITY int toupper(int __c) {return __libcpp_toupper(__c);}
#else // toupper
using ::toupper;
#endif // toupper
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CCTYPE

57
libcxx/include/cerrno Normal file
View File

@ -0,0 +1,57 @@
// -*- C++ -*-
//===-------------------------- cerrno ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CERRNO
#define _LIBCPP_CERRNO
/*
cerrno synopsis
Macros:
EDOM
EILSEQ // C99
ERANGE
errno
*/
#include <__config>
#include <errno.h>
#pragma GCC system_header
#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
const int __elast1 = ELAST+1;
const int __elast2 = ELAST+2;
#undef ELAST
#ifdef ENOTRECOVERABLE
#define EOWNERDEAD __elast1
#define ELAST EOWNERDEAD
#elif defined(EOWNERDEAD)
#define ENOTRECOVERABLE __elast1
#define ELAST ENOTRECOVERABLE
#else
#define EOWNERDEAD __elast1
#define ENOTRECOVERABLE __elast2
#define ELAST ENOTRECOVERABLE
#endif
#endif
#endif // _LIBCPP_CERRNO

80
libcxx/include/cfenv Normal file
View File

@ -0,0 +1,80 @@
// -*- C++ -*-
//===---------------------------- cctype ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CFENV
#define _LIBCPP_CFENV
/*
cfenv synopsis
This entire header is C99 / C++0X
Macros:
FE_DIVBYZERO
FE_INEXACT
FE_INVALID
FE_OVERFLOW
FE_UNDERFLOW
FE_ALL_EXCEPT
FE_DOWNWARD
FE_TONEAREST
FE_TOWARDZERO
FE_UPWARD
FE_DFL_ENV
namespace std
{
Types:
fenv_t
fexcept_t
int feclearexcept(int excepts);
int fegetexceptflag(fexcept_t* flagp, int excepts);
int feraiseexcept(int excepts);
int fesetexceptflag(const fexcept_t* flagp, int excepts);
int fetestexcept(int excepts);
int fegetround();
int fesetround(int round);
int fegetenv(fenv_t* envp);
int feholdexcept(fenv_t* envp);
int fesetenv(const fenv_t* envp);
int feupdateenv(const fenv_t* envp);
} // std
*/
#include <__config>
#include <fenv.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::fenv_t;
using ::fexcept_t;
using ::feclearexcept;
using ::fegetexceptflag;
using ::feraiseexcept;
using ::fesetexceptflag;
using ::fetestexcept;
using ::fegetround;
using ::fesetround;
using ::fegetenv;
using ::feholdexcept;
using ::fesetenv;
using ::feupdateenv;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CFENV

76
libcxx/include/cfloat Normal file
View File

@ -0,0 +1,76 @@
// -*- C++ -*-
//===--------------------------- cfloat -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CFLOAT
#define _LIBCPP_CFLOAT
/*
cfloat synopsis
Macros:
FLT_ROUNDS
FLT_EVAL_METHOD // C99
FLT_RADIX
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
DECIMAL_DIG // C99
FLT_DIG
DBL_DIG
LDBL_DIG
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
FLT_MIN_10_EXP
DBL_MIN_10_EXP
LDBL_MIN_10_EXP
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
FLT_MAX_10_EXP
DBL_MAX_10_EXP
LDBL_MAX_10_EXP
FLT_MAX
DBL_MAX
LDBL_MAX
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
FLT_MIN
DBL_MIN
LDBL_MIN
*/
#include <__config>
#include <float.h>
#pragma GCC system_header
#ifndef FLT_EVAL_METHOD
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#endif
#ifndef DECIMAL_DIG
#define DECIMAL_DIG __DECIMAL_DIG__
#endif
#endif // _LIBCPP_CFLOAT

868
libcxx/include/chrono Normal file
View File

@ -0,0 +1,868 @@
// -*- C++ -*-
//===---------------------------- chrono ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CHRONO
#define _LIBCPP_CHRONO
/*
chrono synopsis
namespace std
{
namespace chrono
{
template <class ToDuration, class Rep, class Period>
ToDuration
duration_cast(const duration<Rep, Period>& fd);
template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
template <class Rep>
struct duration_values
{
public:
static Rep zero();
static Rep max();
static Rep min();
};
// duration
template <class Rep, class Period = ratio<1>>
class duration
{
static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
static_assert(Period::num > 0, "duration period must be positive");
public:
typedef Rep rep;
typedef Period period;
duration() = default;
template <class Rep2>
explicit duration(const Rep2& r,
typename enable_if
<
is_convertible<Rep2, rep>::value &&
(treat_as_floating_point<rep>::value ||
!treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
>::type* = 0);
// conversions
template <class Rep2, class Period2>
duration(const duration<Rep2, Period2>& d,
typename enable_if
<
treat_as_floating_point<rep>::value ||
ratio_divide<Period2, period>::type::den == 1
>::type* = 0);
// observer
rep count() const;
// arithmetic
duration operator+() const;
duration operator-() const;
duration& operator++();
duration operator++(int);
duration& operator--();
duration operator--(int);
duration& operator+=(const duration& d);
duration& operator-=(const duration& d);
duration& operator*=(const rep& rhs);
duration& operator/=(const rep& rhs);
// special values
static duration zero();
static duration min();
static duration max();
};
typedef duration<long long, nano> nanoseconds;
typedef duration<long long, micro> microseconds;
typedef duration<long long, milli> milliseconds;
typedef duration<long long > seconds;
typedef duration< long, ratio< 60> > minutes;
typedef duration< long, ratio<3600> > hours;
template <class Clock, class Duration = typename Clock::duration>
class time_point
{
public:
typedef Clock clock;
typedef Duration duration;
typedef typename duration::rep rep;
typedef typename duration::period period;
private:
duration d_; // exposition only
public:
time_point(); // has value "epoch"
explicit time_point(const duration& d); // same as time_point() + d
// conversions
template <class Duration2>
time_point(const time_point<clock, Duration2>& t);
// observer
duration time_since_epoch() const;
// arithmetic
time_point& operator+=(const duration& d);
time_point& operator-=(const duration& d);
// special values
static constexpr time_point min();
static constexpr time_point max();
};
} // chrono
// common_type traits
template <class Rep1, class Period1, class Rep2, class Period2>
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
template <class Clock, class Duration1, class Duration2>
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
namespace chrono {
// duration arithmetic
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
operator*(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
operator*(const Rep1& s, const duration<Rep2, Period>& d);
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
operator/(const duration<Rep1, Period>& d, const Rep2& s);
template <class Rep1, class Period1, class Rep2, class Period2>
typename common_type<Rep1, Rep2>::type
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// duration comparisons
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
// duration_cast
template <class ToDuration, class Rep, class Period>
ToDuration duration_cast(const duration<Rep, Period>& d);
// time_point arithmetic
template <class Clock, class Duration1, class Rep2, class Period2>
time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Rep1, class Period1, class Clock, class Duration2>
time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Rep2, class Period2>
time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
template <class Clock, class Duration1, class Duration2>
typename common_type<Duration1, Duration2>::type
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
// time_point comparisons
template <class Clock, class Duration1, class Duration2>
bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Duration2>
bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Duration2>
bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Duration2>
bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Duration2>
bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
template <class Clock, class Duration1, class Duration2>
bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
// time_point_cast
template <class ToDuration, class Clock, class Duration>
time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
// Clocks
class system_clock
{
public:
typedef microseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<system_clock> time_point;
static const bool is_monotonic = false;
static time_point now();
static time_t to_time_t (const time_point& __t);
static time_point from_time_t(time_t __t);
};
class monotonic_clock
{
public:
typedef nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<monotonic_clock, duration> time_point;
static const bool is_monotonic = true;
static time_point now();
};
typedef monotonic_clock high_resolution_clock;
} // chrono
} // std
*/
#include <__config>
#include <ctime>
#include <type_traits>
#include <ratio>
#include <limits>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono
{
template <class _Rep, class _Period = ratio<1> > class duration;
template <class T>
struct __is_duration : false_type {};
template <class _Rep, class _Period>
struct __is_duration<duration<_Rep, _Period> > : true_type {};
template <class _Rep, class _Period>
struct __is_duration<const duration<_Rep, _Period> > : true_type {};
template <class _Rep, class _Period>
struct __is_duration<volatile duration<_Rep, _Period> > : true_type {};
template <class _Rep, class _Period>
struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {};
} // chrono
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
struct common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> >
{
typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type,
typename __ratio_gcd<_Period1, _Period2>::type> type;
};
namespace chrono {
// duration_cast
template <class _FromDuration, class _ToDuration,
class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type,
bool = _Period::num == 1,
bool = _Period::den == 1>
struct __duration_cast;
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true>
{
_LIBCPP_INLINE_VISIBILITY
_ToDuration operator()(const _FromDuration& __fd) const
{
return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count()));
}
};
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false>
{
_LIBCPP_INLINE_VISIBILITY
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
return _ToDuration(static_cast<typename _ToDuration::rep>(
static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den)));
}
};
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true>
{
_LIBCPP_INLINE_VISIBILITY
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
return _ToDuration(static_cast<typename _ToDuration::rep>(
static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)));
}
};
template <class _FromDuration, class _ToDuration, class _Period>
struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false>
{
_LIBCPP_INLINE_VISIBILITY
_ToDuration operator()(const _FromDuration& __fd) const
{
typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct;
return _ToDuration(static_cast<typename _ToDuration::rep>(
static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num)
/ static_cast<_Ct>(_Period::den)));
}
};
template <class _ToDuration, class _Rep, class _Period>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
__is_duration<_ToDuration>::value,
_ToDuration
>::type
duration_cast(const duration<_Rep, _Period>& __fd)
{
return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd);
}
template <class _Rep> struct treat_as_floating_point : is_floating_point<_Rep> {};
template <class _Rep>
struct duration_values
{
public:
_LIBCPP_INLINE_VISIBILITY static _Rep zero() {return _Rep(0);}
_LIBCPP_INLINE_VISIBILITY static _Rep max() {return numeric_limits<_Rep>::max();}
_LIBCPP_INLINE_VISIBILITY static _Rep min() {return numeric_limits<_Rep>::lowest();}
};
// duration
template <class _Rep, class _Period>
class duration
{
static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration");
static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio");
static_assert(_Period::num > 0, "duration period must be positive");
public:
typedef _Rep rep;
typedef _Period period;
private:
rep __rep_;
public:
_LIBCPP_INLINE_VISIBILITY duration() {} // = default;
template <class _Rep2>
_LIBCPP_INLINE_VISIBILITY
explicit duration(const _Rep2& __r,
typename enable_if
<
is_convertible<_Rep2, rep>::value &&
(treat_as_floating_point<rep>::value ||
!treat_as_floating_point<_Rep2>::value)
>::type* = 0)
: __rep_(__r) {}
// conversions
template <class _Rep2, class _Period2>
_LIBCPP_INLINE_VISIBILITY
duration(const duration<_Rep2, _Period2>& __d,
typename enable_if
<
treat_as_floating_point<rep>::value ||
(ratio_divide<_Period2, period>::type::den == 1 &&
!treat_as_floating_point<_Rep2>::value)
>::type* = 0)
: __rep_(_STD::chrono::duration_cast<duration>(__d).count()) {}
// observer
_LIBCPP_INLINE_VISIBILITY rep count() const {return __rep_;}
// arithmetic
_LIBCPP_INLINE_VISIBILITY duration operator+() const {return *this;}
_LIBCPP_INLINE_VISIBILITY duration operator-() const {return duration(-__rep_);}
_LIBCPP_INLINE_VISIBILITY duration& operator++() {++__rep_; return *this;}
_LIBCPP_INLINE_VISIBILITY duration operator++(int) {return duration(__rep_++);}
_LIBCPP_INLINE_VISIBILITY duration& operator--() {--__rep_; return *this;}
_LIBCPP_INLINE_VISIBILITY duration operator--(int) {return duration(__rep_--);}
_LIBCPP_INLINE_VISIBILITY duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;}
_LIBCPP_INLINE_VISIBILITY duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;}
// special values
_LIBCPP_INLINE_VISIBILITY static duration zero() {return duration(duration_values<rep>::zero());}
_LIBCPP_INLINE_VISIBILITY static duration min() {return duration(duration_values<rep>::min());}
_LIBCPP_INLINE_VISIBILITY static duration max() {return duration(duration_values<rep>::max());}
};
typedef duration<long long, nano> nanoseconds;
typedef duration<long long, micro> microseconds;
typedef duration<long long, milli> milliseconds;
typedef duration<long long > seconds;
typedef duration< long, ratio< 60> > minutes;
typedef duration< long, ratio<3600> > hours;
// Duration ==
template <class _LhsDuration, class _RhsDuration>
struct __duration_eq
{
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
{
typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
return _Ct(__lhs).count() == _Ct(__rhs).count();
}
};
template <class _LhsDuration>
struct __duration_eq<_LhsDuration, _LhsDuration>
{
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
{return __lhs.count() == __rhs.count();}
};
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
}
// Duration !=
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return !(__lhs == __rhs);
}
// Duration <
template <class _LhsDuration, class _RhsDuration>
struct __duration_lt
{
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs)
{
typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
return _Ct(__lhs).count() < _Ct(__rhs).count();
}
};
template <class _LhsDuration>
struct __duration_lt<_LhsDuration, _LhsDuration>
{
_LIBCPP_INLINE_VISIBILITY
bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs)
{return __lhs.count() < __rhs.count();}
};
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
}
// Duration >
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return __rhs < __lhs;
}
// Duration <=
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return !(__rhs < __lhs);
}
// Duration >=
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return !(__lhs < __rhs);
}
// Duration +
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type __r = __lhs;
__r += __rhs;
return __r;
}
// Duration -
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type __r = __lhs;
__r -= __rhs;
return __r;
}
// Duration *
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
duration<typename common_type<_Rep1, _Rep2>::type, _Period>
>::type
operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
duration<_Cr, _Period> __r = __d;
__r *= static_cast<_Cr>(__s);
return __r;
}
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value,
duration<typename common_type<_Rep1, _Rep2>::type, _Period>
>::type
operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
{
return __d * __s;
}
// Duration /
template <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
struct __duration_divide_result
{
};
template <class _Duration, class _Rep2,
bool = is_convertible<_Rep2,
typename common_type<typename _Duration::rep, _Rep2>::type>::value>
struct __duration_divide_imp
{
};
template <class _Rep1, class _Period, class _Rep2>
struct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
{
typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
};
template <class _Rep1, class _Period, class _Rep2>
struct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
: __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
{
};
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
duration<_Cr, _Period> __r = __d;
__r /= static_cast<_Cr>(__s);
return __r;
}
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
typename common_type<_Rep1, _Rep2>::type
operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct;
return _Ct(__lhs).count() / _Ct(__rhs).count();
}
// Duration %
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
duration<_Cr, _Period> __r = __d;
__r %= static_cast<_Cr>(__s);
return __r;
}
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type __r = __lhs;
__r %= __rhs;
return __r;
}
//////////////////////////////////////////////////////////
///////////////////// time_point /////////////////////////
//////////////////////////////////////////////////////////
template <class _Clock, class _Duration = typename _Clock::duration>
class time_point
{
static_assert(__is_duration<_Duration>::value,
"Second template parameter of time_point must be a std::chrono::duration");
public:
typedef _Clock clock;
typedef _Duration duration;
typedef typename duration::rep rep;
typedef typename duration::period period;
private:
duration __d_;
public:
_LIBCPP_INLINE_VISIBILITY time_point() : __d_(duration::zero()) {}
_LIBCPP_INLINE_VISIBILITY explicit time_point(const duration& __d) : __d_(__d) {}
// conversions
template <class _Duration2>
_LIBCPP_INLINE_VISIBILITY
time_point(const time_point<clock, _Duration2>& t,
typename enable_if
<
is_convertible<_Duration2, duration>::value
>::type* = 0)
: __d_(t.time_since_epoch()) {}
// observer
_LIBCPP_INLINE_VISIBILITY duration time_since_epoch() const {return __d_;}
// arithmetic
_LIBCPP_INLINE_VISIBILITY time_point& operator+=(const duration& __d) {__d_ += __d;}
_LIBCPP_INLINE_VISIBILITY time_point& operator-=(const duration& __d) {__d_ -= __d;}
// special values
_LIBCPP_INLINE_VISIBILITY static time_point min() {return time_point(duration::min());}
_LIBCPP_INLINE_VISIBILITY static time_point max() {return time_point(duration::max());}
};
} // chrono
template <class _Clock, class _Duration1, class _Duration2>
struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> >
{
typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
};
namespace chrono {
template <class _ToDuration, class _Clock, class _Duration>
inline _LIBCPP_INLINE_VISIBILITY
time_point<_Clock, _ToDuration>
time_point_cast(const time_point<_Clock, _Duration>& __t)
{
return time_point<_Clock, _ToDuration>(_STD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch()));
}
// time_point ==
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return __lhs.time_since_epoch() == __rhs.time_since_epoch();
}
// time_point !=
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return !(__lhs == __rhs);
}
// time_point <
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return __lhs.time_since_epoch() < __rhs.time_since_epoch();
}
// time_point >
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return __rhs < __lhs;
}
// time_point <=
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return !(__rhs < __lhs);
}
// time_point >=
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return !(__lhs < __rhs);
}
// time_point operator+(time_point x, duration y);
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
_Tr __r(__lhs.time_since_epoch());
__r += __rhs;
return __r;
}
// time_point operator+(duration x, time_point y);
template <class _Rep1, class _Period1, class _Clock, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return __rhs + __lhs;
}
// time_point operator-(time_point x, duration y);
template <class _Clock, class _Duration1, class _Rep2, class _Period2>
inline _LIBCPP_INLINE_VISIBILITY
time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs)
{
return __lhs + (-__rhs);
}
// duration operator-(time_point x, time_point y);
template <class _Clock, class _Duration1, class _Duration2>
inline _LIBCPP_INLINE_VISIBILITY
typename common_type<_Duration1, _Duration2>::type
operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs)
{
return __lhs.time_since_epoch() - __rhs.time_since_epoch();
}
//////////////////////////////////////////////////////////
/////////////////////// clocks ///////////////////////////
//////////////////////////////////////////////////////////
class system_clock
{
public:
typedef microseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<system_clock> time_point;
static const bool is_monotonic = false;
static time_point now();
static time_t to_time_t (const time_point& __t);
static time_point from_time_t(time_t __t);
};
class monotonic_clock
{
public:
typedef nanoseconds duration;
typedef duration::rep rep;
typedef duration::period period;
typedef chrono::time_point<monotonic_clock, duration> time_point;
static const bool is_monotonic = true;
static time_point now();
};
typedef monotonic_clock high_resolution_clock;
} // chrono
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CHRONO

257
libcxx/include/cinttypes Normal file
View File

@ -0,0 +1,257 @@
// -*- C++ -*-
//===--------------------------- cinttypes --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CINTTYPES
#define _LIBCPP_CINTTYPES
/*
cinttypes synopsis
This entire header is C99 / C++0X
#include <cstdint> // <cinttypes> includes <cstdint>
Macros:
PRId8
PRId16
PRId32
PRId64
PRIdLEAST8
PRIdLEAST16
PRIdLEAST32
PRIdLEAST64
PRIdFAST8
PRIdFAST16
PRIdFAST32
PRIdFAST64
PRIdMAX
PRIdPTR
PRIi8
PRIi16
PRIi32
PRIi64
PRIiLEAST8
PRIiLEAST16
PRIiLEAST32
PRIiLEAST64
PRIiFAST8
PRIiFAST16
PRIiFAST32
PRIiFAST64
PRIiMAX
PRIiPTR
PRIo8
PRIo16
PRIo32
PRIo64
PRIoLEAST8
PRIoLEAST16
PRIoLEAST32
PRIoLEAST64
PRIoFAST8
PRIoFAST16
PRIoFAST32
PRIoFAST64
PRIoMAX
PRIoPTR
PRIu8
PRIu16
PRIu32
PRIu64
PRIuLEAST8
PRIuLEAST16
PRIuLEAST32
PRIuLEAST64
PRIuFAST8
PRIuFAST16
PRIuFAST32
PRIuFAST64
PRIuMAX
PRIuPTR
PRIx8
PRIx16
PRIx32
PRIx64
PRIxLEAST8
PRIxLEAST16
PRIxLEAST32
PRIxLEAST64
PRIxFAST8
PRIxFAST16
PRIxFAST32
PRIxFAST64
PRIxMAX
PRIxPTR
PRIX8
PRIX16
PRIX32
PRIX64
PRIXLEAST8
PRIXLEAST16
PRIXLEAST32
PRIXLEAST64
PRIXFAST8
PRIXFAST16
PRIXFAST32
PRIXFAST64
PRIXMAX
PRIXPTR
SCNd8
SCNd16
SCNd32
SCNd64
SCNdLEAST8
SCNdLEAST16
SCNdLEAST32
SCNdLEAST64
SCNdFAST8
SCNdFAST16
SCNdFAST32
SCNdFAST64
SCNdMAX
SCNdPTR
SCNi8
SCNi16
SCNi32
SCNi64
SCNiLEAST8
SCNiLEAST16
SCNiLEAST32
SCNiLEAST64
SCNiFAST8
SCNiFAST16
SCNiFAST32
SCNiFAST64
SCNiMAX
SCNiPTR
SCNo8
SCNo16
SCNo32
SCNo64
SCNoLEAST8
SCNoLEAST16
SCNoLEAST32
SCNoLEAST64
SCNoFAST8
SCNoFAST16
SCNoFAST32
SCNoFAST64
SCNoMAX
SCNoPTR
SCNu8
SCNu16
SCNu32
SCNu64
SCNuLEAST8
SCNuLEAST16
SCNuLEAST32
SCNuLEAST64
SCNuFAST8
SCNuFAST16
SCNuFAST32
SCNuFAST64
SCNuMAX
SCNuPTR
SCNx8
SCNx16
SCNx32
SCNx64
SCNxLEAST8
SCNxLEAST16
SCNxLEAST32
SCNxLEAST64
SCNxFAST8
SCNxFAST16
SCNxFAST32
SCNxFAST64
SCNxMAX
SCNxPTR
namespace std
{
Types:
imaxdiv_t
intmax_t imaxabs(intmax_t j);
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
} // std
*/
#include <__config>
#include <cstdint>
#include <inttypes.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using::imaxdiv_t;
using::imaxabs;
using::imaxdiv;
using::strtoimax;
using::strtoumax;
using::wcstoimax;
using::wcstoumax;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CINTTYPES

23
libcxx/include/ciso646 Normal file
View File

@ -0,0 +1,23 @@
// -*- C++ -*-
//===--------------------------- ciso646 ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CISO646
#define _LIBCPP_CISO646
/*
ciso646 synopsis
*/
#include <__config>
#pragma GCC system_header
#endif // _LIBCPP_CISO646

46
libcxx/include/climits Normal file
View File

@ -0,0 +1,46 @@
// -*- C++ -*-
//===--------------------------- climits ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CLIMITS
#define _LIBCPP_CLIMITS
/*
climits synopsis
Macros:
CHAR_BIT
SCHAR_MIN
SCHAR_MAX
UCHAR_MAX
CHAR_MIN
CHAR_MAX
MB_LEN_MAX
SHRT_MIN
SHRT_MAX
USHRT_MAX
INT_MIN
INT_MAX
UINT_MAX
LONG_MIN
LONG_MAX
ULONG_MAX
LLONG_MIN // C99
LLONG_MAX // C99
ULLONG_MAX // C99
*/
#include <__config>
#include <limits.h>
#pragma GCC system_header
#endif // _LIBCPP_CLIMITS

51
libcxx/include/clocale Normal file
View File

@ -0,0 +1,51 @@
// -*- C++ -*-
//===--------------------------- clocale ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CLOCALE
#define _LIBCPP_CLOCALE
/*
clocale synopsis
Macros:
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME
NULL
namespace std
{
struct lconv;
char* setlocale(int category, const char* locale);
lconv* localeconv();
} // std
*/
#include <__config>
#include <locale.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::lconv;
using ::setlocale;
using ::localeconv;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CLOCALE

1644
libcxx/include/cmath Normal file

File diff suppressed because it is too large Load Diff

1528
libcxx/include/complex Normal file

File diff suppressed because it is too large Load Diff

25
libcxx/include/complex.h Normal file
View File

@ -0,0 +1,25 @@
// -*- C++ -*-
//===--------------------------- complex.h --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_COMPLEX_H
#define _LIBCPP_COMPLEX_H
/*
complex.h synopsis
#include <ccomplex>
*/
#include <ccomplex>
#pragma GCC system_header
#endif // _LIBCPP_COMPLEX_H

View File

@ -0,0 +1,249 @@
// -*- C++ -*-
//===---------------------- condition_variable ----------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CONDITION_VARIABLE
#define _LIBCPP_CONDITION_VARIABLE
/*
condition_variable synopsis
namespace std
{
enum class cv_status { no_timeout, timeout };
class condition_variable
{
public:
condition_variable();
~condition_variable();
condition_variable(const condition_variable&) = delete;
condition_variable& operator=(const condition_variable&) = delete;
void notify_one();
void notify_all();
void wait(unique_lock<mutex>& lock);
template <class Predicate>
void wait(unique_lock<mutex>& lock, Predicate pred);
template <class Clock, class Duration>
cv_status
wait_until(unique_lock<mutex>& lock,
const chrono::time_point<Clock, Duration>& abs_time);
template <class Clock, class Duration, class Predicate>
bool
wait_until(unique_lock<mutex>& lock,
const chrono::time_point<Clock, Duration>& abs_time,
Predicate pred);
template <class Rep, class Period>
cv_status
wait_for(unique_lock<mutex>& lock,
const chrono::duration<Rep, Period>& rel_time);
template <class Rep, class Period, class Predicate>
bool
wait_for(unique_lock<mutex>& lock,
const chrono::duration<Rep, Period>& rel_time,
Predicate pred);
typedef pthread_cond_t* native_handle_type;
native_handle_type native_handle();
};
class condition_variable_any
{
public:
condition_variable_any();
~condition_variable_any();
condition_variable_any(const condition_variable_any&) = delete;
condition_variable_any& operator=(const condition_variable_any&) = delete;
void notify_one();
void notify_all();
template <class Lock>
void wait(Lock& lock);
template <class Lock, class Predicate>
void wait(Lock& lock, Predicate pred);
template <class Lock, class Clock, class Duration>
cv_status
wait_until(Lock& lock,
const chrono::time_point<Clock, Duration>& abs_time);
template <class Lock, class Clock, class Duration, class Predicate>
bool
wait_until(Lock& lock,
const chrono::time_point<Clock, Duration>& abs_time,
Predicate pred);
template <class Lock, class Rep, class Period>
cv_status
wait_for(Lock& lock,
const chrono::duration<Rep, Period>& rel_time);
template <class Lock, class Rep, class Period, class Predicate>
bool
wait_for(Lock& lock,
const chrono::duration<Rep, Period>& rel_time,
Predicate pred);
};
} // std
*/
#include <__config>
#include <__mutex_base>
#include <memory>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
class condition_variable_any
{
condition_variable __cv_;
shared_ptr<mutex> __mut_;
public:
condition_variable_any();
void notify_one();
void notify_all();
template <class _Lock>
void wait(_Lock& __lock);
template <class _Lock, class _Predicate>
void wait(_Lock& __lock, _Predicate __pred);
template <class _Lock, class _Clock, class _Duration>
cv_status
wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t);
template <class _Lock, class _Clock, class _Duration, class _Predicate>
bool
wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred);
template <class _Lock, class _Rep, class _Period>
cv_status
wait_for(_Lock& __lock,
const chrono::duration<_Rep, _Period>& __d);
template <class _Lock, class _Rep, class _Period, class _Predicate>
bool
wait_for(_Lock& __lock,
const chrono::duration<_Rep, _Period>& __d,
_Predicate __pred);
};
inline
condition_variable_any::condition_variable_any()
: __mut_(make_shared<mutex>()) {}
inline
void
condition_variable_any::notify_one()
{
{lock_guard<mutex> _(*__mut_);}
__cv_.notify_one();
}
inline
void
condition_variable_any::notify_all()
{
{lock_guard<mutex> _(*__mut_);}
__cv_.notify_all();
}
struct __lock_external
{
template <class _Lock>
void operator()(_Lock* __m) {__m->lock();}
};
template <class _Lock>
void
condition_variable_any::wait(_Lock& __lock)
{
shared_ptr<mutex> __mut = __mut_;
unique_lock<mutex> __lk(*__mut);
__lock.unlock();
unique_ptr<_Lock, __lock_external> __(&__lock);
lock_guard<unique_lock<mutex> > _(__lk, adopt_lock);
__cv_.wait(__lk);
} // __mut_.unlock(), __lock.lock()
template <class _Lock, class _Predicate>
inline
void
condition_variable_any::wait(_Lock& __lock, _Predicate __pred)
{
while (!__pred())
wait(__lock);
}
template <class _Lock, class _Clock, class _Duration>
cv_status
condition_variable_any::wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t)
{
shared_ptr<mutex> __mut = __mut_;
unique_lock<mutex> __lk(*__mut);
__lock.unlock();
unique_ptr<_Lock, __lock_external> __(&__lock);
lock_guard<unique_lock<mutex> > _(__lk, adopt_lock);
return __cv_.wait_until(__lk, __t);
} // __mut_.unlock(), __lock.lock()
template <class _Lock, class _Clock, class _Duration, class _Predicate>
inline
bool
condition_variable_any::wait_until(_Lock& __lock,
const chrono::time_point<_Clock, _Duration>& __t,
_Predicate __pred)
{
while (!__pred())
if (wait_until(__lock, __t) == cv_status::timeout)
return __pred();
return true;
}
template <class _Lock, class _Rep, class _Period>
inline
cv_status
condition_variable_any::wait_for(_Lock& __lock,
const chrono::duration<_Rep, _Period>& __d)
{
return wait_until(__lock, chrono::monotonic_clock::now() + __d);
}
template <class _Lock, class _Rep, class _Period, class _Predicate>
inline
bool
condition_variable_any::wait_for(_Lock& __lock,
const chrono::duration<_Rep, _Period>& __d,
_Predicate __pred)
{
return wait_until(__lock, chrono::monotonic_clock::now() + __d,
_STD::move(__pred));
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CONDITION_VARIABLE

50
libcxx/include/csetjmp Normal file
View File

@ -0,0 +1,50 @@
// -*- C++ -*-
//===--------------------------- csetjmp ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSETJMP
#define _LIBCPP_CSETJMP
/*
csetjmp synopsis
Macros:
setjmp
namespace std
{
Types:
jmp_buf
void longjmp(jmp_buf env, int val);
} // std
*/
#include <__config>
#include <setjmp.h>
#pragma GCC system_header
#ifndef setjmp
#define setjmp(env) setjmp(env)
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
using ::jmp_buf;
using ::longjmp;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSETJMP

56
libcxx/include/csignal Normal file
View File

@ -0,0 +1,56 @@
// -*- C++ -*-
//===--------------------------- csignal ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSIGNAL
#define _LIBCPP_CSIGNAL
/*
csignal synopsis
Macros:
SIG_DFL
SIG_ERR
SIG_IGN
SIGABRT
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
namespace std
{
Types:
sig_atomic_t
void (*signal(int sig, void (*func)(int)))(int);
int raise(int sig);
} // std
*/
#include <__config>
#include <signal.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::sig_atomic_t;
using ::signal;
using ::raise;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSIGNAL

46
libcxx/include/cstdarg Normal file
View File

@ -0,0 +1,46 @@
// -*- C++ -*-
//===--------------------------- cstdarg ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDARG
#define _LIBCPP_CSTDARG
/*
cstdarg synopsis
Macros:
type va_arg(va_list ap, type);
void va_copy(va_list dest, va_list src); // C99
void va_end(va_list ap);
void va_start(va_list ap, parmN);
namespace std
{
Types:
va_list
} // std
*/
#include <__config>
#include <stdarg.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::va_list;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDARG

30
libcxx/include/cstdbool Normal file
View File

@ -0,0 +1,30 @@
// -*- C++ -*-
//===--------------------------- cstdbool ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDBOOL
#define _LIBCPP_CSTDBOOL
/*
cstdbool synopsis
Macros:
__bool_true_false_are_defined
*/
#include <__config>
#pragma GCC system_header
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#endif // _LIBCPP_CSTDBOOL

88
libcxx/include/cstddef Normal file
View File

@ -0,0 +1,88 @@
// -*- C++ -*-
//===--------------------------- cstddef ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDDEF
#define _LIBCPP_CSTDDEF
/*
cstddef synopsis
Macros:
offsetof(type,member-designator)
NULL
namespace std
{
Types:
ptrdiff_t
size_t
max_align_t
nullptr_t
} // std
*/
#include <__config>
#include <stddef.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::ptrdiff_t;
using ::size_t;
typedef long double max_align_t;
#ifdef _LIBCPP_HAS_NO_NULLPTR
struct nullptr_t
{
void* _;
struct __nat {int __for_bool_;};
_LIBCPP_ALWAYS_INLINE nullptr_t(int __nat::*) {}
_LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;}
template <class T>
_LIBCPP_ALWAYS_INLINE
operator T* () const {return 0;}
template <class T, class U>
_LIBCPP_ALWAYS_INLINE
operator T U::* () const {return 0;}
friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE bool operator<(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE bool operator<=(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE bool operator>(nullptr_t, nullptr_t) {return false;}
friend _LIBCPP_ALWAYS_INLINE bool operator>=(nullptr_t, nullptr_t) {return true;}
};
inline _LIBCPP_ALWAYS_INLINE nullptr_t __get_nullptr_t() {return nullptr_t(0);}
#define nullptr _STD::__get_nullptr_t()
#else
typedef decltype(nullptr) nullptr_t;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDDEF

189
libcxx/include/cstdint Normal file
View File

@ -0,0 +1,189 @@
// -*- C++ -*-
//===--------------------------- cstdint ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDINT
#define _LIBCPP_CSTDINT
/*
cstdint synopsis
Macros:
INT8_MIN
INT16_MIN
INT32_MIN
INT64_MIN
INT8_MAX
INT16_MAX
INT32_MAX
INT64_MAX
UINT8_MAX
UINT16_MAX
UINT32_MAX
UINT64_MAX
INT_LEAST8_MIN
INT_LEAST16_MIN
INT_LEAST32_MIN
INT_LEAST64_MIN
INT_LEAST8_MAX
INT_LEAST16_MAX
INT_LEAST32_MAX
INT_LEAST64_MAX
UINT_LEAST8_MAX
UINT_LEAST16_MAX
UINT_LEAST32_MAX
UINT_LEAST64_MAX
INT_FAST8_MIN
INT_FAST16_MIN
INT_FAST32_MIN
INT_FAST64_MIN
INT_FAST8_MAX
INT_FAST16_MAX
INT_FAST32_MAX
INT_FAST64_MAX
UINT_FAST8_MAX
UINT_FAST16_MAX
UINT_FAST32_MAX
UINT_FAST64_MAX
INTPTR_MIN
INTPTR_MAX
UINTPTR_MAX
INTMAX_MIN
INTMAX_MAX
UINTMAX_MAX
PTRDIFF_MIN
PTRDIFF_MAX
SIG_ATOMIC_MIN
SIG_ATOMIC_MAX
SIZE_MAX
WCHAR_MIN
WCHAR_MAX
WINT_MIN
WINT_MAX
INT8_C(value)
INT16_C(value)
INT32_C(value)
INT64_C(value)
UINT8_C(value)
UINT16_C(value)
UINT32_C(value)
UINT64_C(value)
INTMAX_C(value)
UINTMAX_C(value)
namespace std
{
Types:
int8_t
int16_t
int32_t
int64_t
uint8_t
uint16_t
uint32_t
uint64_t
int_least8_t
int_least16_t
int_least32_t
int_least64_t
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
intptr_t
uintptr_t
intmax_t
uintmax_t
} // std
*/
#include <__config>
#include <stdint.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using::int8_t;
using::int16_t;
using::int32_t;
using::int64_t;
using::uint8_t;
using::uint16_t;
using::uint32_t;
using::uint64_t;
using::int_least8_t;
using::int_least16_t;
using::int_least32_t;
using::int_least64_t;
using::uint_least8_t;
using::uint_least16_t;
using::uint_least32_t;
using::uint_least64_t;
using::int_fast8_t;
using::int_fast16_t;
using::int_fast32_t;
using::int_fast64_t;
using::uint_fast8_t;
using::uint_fast16_t;
using::uint_fast32_t;
using::uint_fast64_t;
using::intptr_t;
using::uintptr_t;
using::intmax_t;
using::uintmax_t;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDINT

159
libcxx/include/cstdio Normal file
View File

@ -0,0 +1,159 @@
// -*- C++ -*-
//===---------------------------- cstdio ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDIO
#define _LIBCPP_CSTDIO
/*
cstdio synopsis
Macros:
BUFSIZ
EOF
FILENAME_MAX
FOPEN_MAX
L_tmpnam
NULL
SEEK_CUR
SEEK_END
SEEK_SET
TMP_MAX
_IOFBF
_IOLBF
_IONBF
stderr
stdin
stdout
namespace std
{
Types:
FILE
fpos_t
size_t
int remove(const char* filename);
int rename(const char* old, const char* new);
FILE* tmpfile(void);
char* tmpnam(char* s);
int fclose(FILE* stream);
int fflush(FILE* stream);
FILE* fopen(const char* restrict filename, const char* restrict mode);
FILE* freopen(const char* restrict filename, const char * restrict mode,
FILE * restrict stream);
void setbuf(FILE* restrict stream, char* restrict buf);
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);
int fprintf(FILE* restrict stream, const char* restrict format, ...);
int fscanf(FILE* restrict stream, const char * restrict format, ...);
int printf(const char* restrict format, ...);
int scanf(const char* restrict format, ...);
int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99
int sprintf(char* restrict s, const char* restrict format, ...);
int sscanf(const char* restrict s, const char* restrict format, ...);
int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg);
int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99
int vprintf(const char* restrict format, va_list arg);
int vscanf(const char* restrict format, va_list arg); // C99
int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99
va_list arg);
int vsprintf(char* restrict s, const char* restrict format, va_list arg);
int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99
int fgetc(FILE* stream);
char* fgets(char* restrict s, int n, FILE* restrict stream);
int fputc(int c, FILE* stream);
int fputs(const char* restrict s, FILE* restrict stream);
int getc(FILE* stream);
int getchar(void);
char* gets(char* s);
int putc(int c, FILE* stream);
int putchar(int c);
int puts(const char* s);
int ungetc(int c, FILE* stream);
size_t fread(void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb,
FILE* restrict stream);
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);
int fseek(FILE* stream, long offset, int whence);
int fsetpos(FILE*stream, const fpos_t* pos);
long ftell(FILE* stream);
void rewind(FILE* stream);
void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);
} // std
*/
#include <__config>
#include <stdio.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::FILE;
using ::fpos_t;
using ::size_t;
using ::remove;
using ::rename;
using ::tmpfile;
using ::tmpnam;
using ::fclose;
using ::fflush;
using ::fopen;
using ::freopen;
using ::setbuf;
using ::setvbuf;
using ::fprintf;
using ::fscanf;
using ::printf;
using ::scanf;
using ::snprintf;
using ::sprintf;
using ::sscanf;
using ::vfprintf;
using ::vfscanf;
using ::vprintf;
using ::vscanf;
using ::vsnprintf;
using ::vsprintf;
using ::vsscanf;
using ::fgetc;
using ::fgets;
using ::fputc;
using ::fputs;
using ::getc;
using ::getchar;
using ::gets;
using ::putc;
using ::putchar;
using ::puts;
using ::ungetc;
using ::fread;
using ::fwrite;
using ::fgetpos;
using ::fseek;
using ::fsetpos;
using ::ftell;
using ::rewind;
using ::clearerr;
using ::feof;
using ::ferror;
using ::perror;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDIO

138
libcxx/include/cstdlib Normal file
View File

@ -0,0 +1,138 @@
// -*- C++ -*-
//===--------------------------- cstdlib ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTDLIB
#define _LIBCPP_CSTDLIB
/*
cstdlib synopsis
Macros:
EXIT_FAILURE
EXIT_SUCCESS
MB_CUR_MAX
NULL
RAND_MAX
namespace std
{
Types:
size_t
div_t
ldiv_t
lldiv_t // C99
double atof (const char* nptr);
int atoi (const char* nptr);
long atol (const char* nptr);
long long atoll(const char* nptr); // C99
double strtod (const char* restrict nptr, char** restrict endptr);
float strtof (const char* restrict nptr, char** restrict endptr); // C99
long double strtold (const char* restrict nptr, char** restrict endptr); // C99
long strtol (const char* restrict nptr, char** restrict endptr, int base);
long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
int rand(void);
void srand(unsigned int seed);
void* calloc(size_t nmemb, size_t size);
void free(void* ptr);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
void abort(void);
int atexit(void (*func)(void));
void exit(int status);
void _Exit(int status);
char* getenv(const char* name);
int system(const char* string);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
void qsort(void* base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
int abs( int j);
long abs( long j);
long long abs(long long j); // C++0X
long labs( long j);
long long llabs(long long j); // C99
div_t div( int numer, int denom);
ldiv_t div( long numer, long denom);
lldiv_t div(long long numer, long long denom); // C++0X
ldiv_t ldiv( long numer, long denom);
lldiv_t lldiv(long long numer, long long denom); // C99
int mblen(const char* s, size_t n);
int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
int wctomb(char* s, wchar_t wchar);
size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
} // std
*/
#include <__config>
#include <stdlib.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::size_t;
using ::div_t;
using ::ldiv_t;
using ::lldiv_t;
using ::atof;
using ::atoi;
using ::atol;
using ::atoll;
using ::strtod;
using ::strtof;
using ::strtold;
using ::strtol;
using ::strtoll;
using ::strtoul;
using ::strtoull;
using ::rand;
using ::srand;
using ::calloc;
using ::free;
using ::malloc;
using ::realloc;
using ::abort;
using ::atexit;
using ::exit;
using ::_Exit;
using ::getenv;
using ::system;
using ::bsearch;
using ::qsort;
using ::abs;
using ::labs;
using ::llabs;
using ::div;
using ::ldiv;
using ::lldiv;
using ::mblen;
using ::mbtowc;
using ::wctomb;
using ::mbstowcs;
using ::wcstombs;
inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) {return labs(__x);}
inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) {return llabs(__x);}
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) {return ldiv(__x, __y);}
inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) {return lldiv(__x, __y);}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTDLIB

106
libcxx/include/cstring Normal file
View File

@ -0,0 +1,106 @@
// -*- C++ -*-
//===--------------------------- cstring ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CSTRING
#define _LIBCPP_CSTRING
/*
cstring synopsis
Macros:
NULL
namespace std
{
Types:
size_t
void* memcpy(void* restrict s1, const void* restrict s2, size_t n);
void* memmove(void* s1, const void* s2, size_t n);
char* strcpy (char* restrict s1, const char* restrict s2);
char* strncpy(char* restrict s1, const char* restrict s2, size_t n);
char* strcat (char* restrict s1, const char* restrict s2);
char* strncat(char* restrict s1, const char* restrict s2, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
int strcmp (const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
int strcoll(const char* s1, const char* s2);
size_t strxfrm(char* restrict s1, const char* restrict s2, size_t n);
const void* memchr(const void* s, int c, size_t n);
void* memchr( void* s, int c, size_t n);
const char* strchr(const char* s, int c);
char* strchr( char* s, int c);
size_t strcspn(const char* s1, const char* s2);
const char* strpbrk(const char* s1, const char* s2);
char* strpbrk( char* s1, const char* s2);
const char* strrchr(const char* s, int c);
char* strrchr( char* s, int c);
size_t strspn(const char* s1, const char* s2);
const char* strstr(const char* s1, const char* s2);
char* strstr( char* s1, const char* s2);
char* strtok(char* restrict s1, const char* restrict s2);
void* memset(void* s, int c, size_t n);
char* strerror(int errnum);
size_t strlen(const char* s);
} // std
*/
#include <__config>
#include <string.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::size_t;
using ::memcpy;
using ::memmove;
using ::strcpy;
using ::strncpy;
using ::strcat;
using ::strncat;
using ::memcmp;
using ::strcmp;
using ::strncmp;
using ::strcoll;
using ::strxfrm;
inline _LIBCPP_INLINE_VISIBILITY const void* memchr(const void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY void* memchr( void* __s, int __c, size_t __n) {return ::memchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY const char* strchr(const char* __s, int __c) {return ::strchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY char* strchr( char* __s, int __c) {return ::strchr(__s, __c);}
using ::strcspn;
inline _LIBCPP_INLINE_VISIBILITY const char* strpbrk(const char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY char* strpbrk( char* __s1, const char* __s2) {return ::strpbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int __c) {return ::strrchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY char* strrchr( char* __s, int __c) {return ::strrchr(__s, __c);}
using ::strspn;
inline _LIBCPP_INLINE_VISIBILITY const char* strstr(const char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY char* strstr( char* __s1, const char* __s2) {return ::strstr(__s1, __s2);}
using ::strtok;
using ::memset;
using ::strerror;
using ::strlen;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CSTRING

27
libcxx/include/ctgmath Normal file
View File

@ -0,0 +1,27 @@
// -*- C++ -*-
//===-------------------------- ctgmath -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CTGMATH
#define _LIBCPP_CTGMATH
/*
ctgmath synopsis
#include <ccomplex>
#include <cmath>
*/
#include <ccomplex>
#include <cmath>
#pragma GCC system_header
#endif // _LIBCPP_CTGMATH

70
libcxx/include/ctime Normal file
View File

@ -0,0 +1,70 @@
// -*- C++ -*-
//===---------------------------- ctime -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CTIME
#define _LIBCPP_CTIME
/*
ctime synopsis
Macros:
NULL
CLOCKS_PER_SEC
namespace std
{
Types:
clock_t
size_t
time_t
tm
clock_t clock();
double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr);
time_t time(time_t* timer);
char* asctime(const tm* timeptr);
char* ctime(const time_t* timer);
tm* gmtime(const time_t* timer);
tm* localtime(const time_t* timer);
size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
const tm* restrict timeptr);
} // std
*/
#include <__config>
#include <time.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::clock_t;
using ::size_t;
using ::time_t;
using ::tm;
using ::clock;
using ::difftime;
using ::mktime;
using ::time;
using ::asctime;
using ::ctime;
using ::gmtime;
using ::localtime;
using ::strftime;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CTIME

195
libcxx/include/cwchar Normal file
View File

@ -0,0 +1,195 @@
// -*- C++ -*-
//===--------------------------- cwchar -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CWCHAR
#define _LIBCPP_CWCHAR
/*
cwchar synopsis
Macros:
NULL
WCHAR_MAX
WCHAR_MIN
WEOF
namespace std
{
Types:
mbstate_t
size_t
tm
wint_t
int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...);
int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...);
int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...);
int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...);
int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg);
int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99
int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg);
int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99
int vwprintf(const wchar_t* restrict format, va_list arg);
int vwscanf(const wchar_t* restrict format, va_list arg); // C99
int wprintf(const wchar_t* restrict format, ...);
int wscanf(const wchar_t* restrict format, ...);
wint_t fgetwc(FILE* stream);
wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream);
wint_t fputwc(wchar_t c, FILE* stream);
int fputws(const wchar_t* restrict s, FILE* restrict stream);
int fwide(FILE* stream, int mode);
wint_t getwc(FILE* stream);
wint_t getwchar();
wint_t putwc(wchar_t c, FILE* stream);
wint_t putwchar(wchar_t c);
wint_t ungetwc(wint_t c, FILE* stream);
double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr);
float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99
long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99
wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2);
wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2);
wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
int wcscmp(const wchar_t* s1, const wchar_t* s2);
int wcscoll(const wchar_t* s1, const wchar_t* s2);
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n);
size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
const wchar_t* wcschr(const wchar_t* s, wchar_t c);
wchar_t* wcschr( wchar_t* s, wchar_t c);
size_t wcscspn(const wchar_t* s1, const wchar_t* s2);
size_t wcslen(const wchar_t* s);
const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2);
wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2);
const wchar_t* wcsrchr(const wchar_t* s, wchar_t c);
wchar_t* wcsrchr( wchar_t* s, wchar_t c);
size_t wcsspn(const wchar_t* s1, const wchar_t* s2);
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2);
wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr);
const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n);
wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n);
int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n);
wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n);
wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n);
size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format,
const tm* restrict timeptr);
wint_t btowc(int c);
int wctob(wint_t c);
int mbsinit(const mbstate_t* ps);
size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps);
size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps);
size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps);
size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len,
mbstate_t* restrict ps);
size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
mbstate_t* restrict ps);
} // std
*/
#include <__config>
#include <cwctype>
#include <wchar.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::mbstate_t;
using ::size_t;
using ::tm;
using ::wint_t;
using ::FILE;
using ::fwprintf;
using ::fwscanf;
using ::swprintf;
using ::swscanf;
using ::vfwprintf;
using ::vfwscanf;
using ::vswprintf;
using ::vswscanf;
using ::vwprintf;
using ::vwscanf;
using ::wprintf;
using ::wscanf;
using ::fgetwc;
using ::fgetws;
using ::fputwc;
using ::fputws;
using ::fwide;
using ::getwc;
using ::getwchar;
using ::putwc;
using ::putwchar;
using ::ungetwc;
using ::wcstod;
using ::wcstof;
using ::wcstold;
using ::wcstol;
using ::wcstoll;
using ::wcstoul;
using ::wcstoull;
using ::wcscpy;
using ::wcsncpy;
using ::wcscat;
using ::wcsncat;
using ::wcscmp;
using ::wcscoll;
using ::wcsncmp;
using ::wcsxfrm;
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);}
using ::wcscspn;
using ::wcslen;
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);}
using ::wcsspn;
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);}
using ::wcstok;
inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);}
using ::wmemcmp;
using ::wmemcpy;
using ::wmemmove;
using ::wmemset;
using ::wcsftime;
using ::btowc;
using ::wctob;
using ::mbsinit;
using ::mbrlen;
using ::mbrtowc;
using ::wcrtomb;
using ::mbsrtowcs;
using ::wcsrtombs;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CWCHAR

211
libcxx/include/cwctype Normal file
View File

@ -0,0 +1,211 @@
// -*- C++ -*-
//===--------------------------- cwctype ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_CWCTYPE
#define _LIBCPP_CWCTYPE
/*
cwctype synopsis
Macros:
WEOF
namespace std
{
Types:
wint_t
wctrans_t
wctype_t
int iswalnum(wint_t wc);
int iswalpha(wint_t wc);
int iswblank(wint_t wc); // C99
int iswcntrl(wint_t wc);
int iswdigit(wint_t wc);
int iswgraph(wint_t wc);
int iswlower(wint_t wc);
int iswprint(wint_t wc);
int iswpunct(wint_t wc);
int iswspace(wint_t wc);
int iswupper(wint_t wc);
int iswxdigit(wint_t wc);
int iswctype(wint_t wc, wctype_t desc);
wctype_t wctype(const char* property);
wint_t towlower(wint_t wc);
wint_t towupper(wint_t wc);
wint_t towctrans(wint_t wc, wctrans_t desc);
wctrans_t wctrans(const char* property);
} // std
*/
#include <__config>
#include <cctype>
#include <wctype.h>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
using ::wint_t;
using ::wctrans_t;
using ::wctype_t;
#ifdef iswalnum
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalnum(wint_t __wc) {return iswalnum(__wc);}
#undef iswalnum
inline _LIBCPP_INLINE_VISIBILITY int iswalnum(wint_t __wc) {return __libcpp_iswalnum(__wc);}
#else
using ::iswalnum;
#endif
#ifdef iswalpha
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalpha(wint_t __wc) {return iswalpha(__wc);}
#undef iswalpha
inline _LIBCPP_INLINE_VISIBILITY int iswalpha(wint_t __wc) {return __libcpp_iswalpha(__wc);}
#else
using ::iswalpha;
#endif
#ifdef iswblank
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswblank(wint_t __wc) {return iswblank(__wc);}
#undef iswblank
inline _LIBCPP_INLINE_VISIBILITY int iswblank(wint_t __wc) {return __libcpp_iswblank(__wc);}
#else
using ::iswblank;
#endif
#ifdef iswcntrl
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswcntrl(wint_t __wc) {return iswcntrl(__wc);}
#undef iswcntrl
inline _LIBCPP_INLINE_VISIBILITY int iswcntrl(wint_t __wc) {return __libcpp_iswcntrl(__wc);}
#else
using ::iswcntrl;
#endif
#ifdef iswdigit
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswdigit(wint_t __wc) {return iswdigit(__wc);}
#undef iswdigit
inline _LIBCPP_INLINE_VISIBILITY int iswdigit(wint_t __wc) {return __libcpp_iswdigit(__wc);}
#else
using ::iswdigit;
#endif
#ifdef iswgraph
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswgraph(wint_t __wc) {return iswgraph(__wc);}
#undef iswgraph
inline _LIBCPP_INLINE_VISIBILITY int iswgraph(wint_t __wc) {return __libcpp_iswgraph(__wc);}
#else
using ::iswgraph;
#endif
#ifdef iswlower
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswlower(wint_t __wc) {return iswlower(__wc);}
#undef iswlower
inline _LIBCPP_INLINE_VISIBILITY int iswlower(wint_t __wc) {return __libcpp_iswlower(__wc);}
#else
using ::iswlower;
#endif
#ifdef iswprint
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswprint(wint_t __wc) {return iswprint(__wc);}
#undef iswprint
inline _LIBCPP_INLINE_VISIBILITY int iswprint(wint_t __wc) {return __libcpp_iswprint(__wc);}
#else
using ::iswprint;
#endif
#ifdef iswpunct
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswpunct(wint_t __wc) {return iswpunct(__wc);}
#undef iswpunct
inline _LIBCPP_INLINE_VISIBILITY int iswpunct(wint_t __wc) {return __libcpp_iswpunct(__wc);}
#else
using ::iswpunct;
#endif
#ifdef iswspace
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswspace(wint_t __wc) {return iswspace(__wc);}
#undef iswspace
inline _LIBCPP_INLINE_VISIBILITY int iswspace(wint_t __wc) {return __libcpp_iswspace(__wc);}
#else
using ::iswspace;
#endif
#ifdef iswupper
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswupper(wint_t __wc) {return iswupper(__wc);}
#undef iswupper
inline _LIBCPP_INLINE_VISIBILITY int iswupper(wint_t __wc) {return __libcpp_iswupper(__wc);}
#else
using ::iswupper;
#endif
#ifdef iswxdigit
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswxdigit(wint_t __wc) {return iswxdigit(__wc);}
#undef iswxdigit
inline _LIBCPP_INLINE_VISIBILITY int iswxdigit(wint_t __wc) {return __libcpp_iswxdigit(__wc);}
#else
using ::iswxdigit;
#endif
#ifdef iswctype
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswctype(wint_t __w, wctype_t __d) {return iswctype(__w, __d);}
#undef iswctype
inline _LIBCPP_INLINE_VISIBILITY int iswctype(wint_t __w, wctype_t __d) {return __libcpp_iswctype(__w, __d);}
#else
using ::iswctype;
#endif
#ifdef wctype
inline _LIBCPP_INLINE_VISIBILITY wctype_t __libcpp_wctype(const char* __p) {return wctype(__p);}
#undef wctype
inline _LIBCPP_INLINE_VISIBILITY wctype_t wctype(const char* __p) {return __libcpp_wctype(__p);}
#else
using ::wctype;
#endif
#ifdef towlower
inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towlower(wint_t __wc) {return towlower(__wc);}
#undef towlower
inline _LIBCPP_INLINE_VISIBILITY wint_t towlower(wint_t __wc) {return __libcpp_towlower(__wc);}
#else
using ::towlower;
#endif
#ifdef towupper
inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towupper(wint_t __wc) {return towupper(__wc);}
#undef towupper
inline _LIBCPP_INLINE_VISIBILITY wint_t towupper(wint_t __wc) {return __libcpp_towupper(__wc);}
#else
using ::towupper;
#endif
#ifdef towctrans
inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towctrans(wint_t __wc, wctype_t __d) {return towctrans(__wc, __d);}
#undef towctrans
inline _LIBCPP_INLINE_VISIBILITY wint_t towctrans(wint_t __wc, wctype_t __d) {return __libcpp_towctrans(__wc, __d);}
#else
using ::towctrans;
#endif
#ifdef wctrans
inline _LIBCPP_INLINE_VISIBILITY wctrans_t __libcpp_wctrans(const char* __p) {return wctrans(__p);}
#undef wctrans
inline _LIBCPP_INLINE_VISIBILITY wctrans_t wctrans(const char* __p) {return __libcpp_wctrans(__p);}
#else
using ::wctrans;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CWCTYPE

2732
libcxx/include/deque Normal file

File diff suppressed because it is too large Load Diff

155
libcxx/include/exception Normal file
View File

@ -0,0 +1,155 @@
// -*- C++ -*-
//===-------------------------- exception ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXCEPTION
#define _LIBCPP_EXCEPTION
/*
exception synopsis
namespace std
{
class exception
{
public:
exception() throw();
exception(const exception&) throw();
exception& operator=(const exception&) throw();
virtual ~exception() throw();
virtual const char* what() const throw();
};
class bad_exception
: public exception
{
public:
bad_exception() throw();
bad_exception(const bad_exception&) throw();
bad_exception& operator=(const bad_exception&) throw();
virtual ~bad_exception() throw();
virtual const char* what() const throw();
};
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected(unexpected_handler f ) throw();
void unexpected [[noreturn]] ();
typedef void (*terminate_handler)();
terminate_handler set_terminate(terminate_handler f ) throw();
void terminate [[noreturn]] ();
bool uncaught_exception() throw();
typedef unspecified exception_ptr;
exception_ptr current_exception();
void rethrow_exception [[noreturn]] (exception_ptr p);
template<class E> exception_ptr make_exception_ptr(E e);
class nested_exception
{
public:
nested_exception() throw();
nested_exception(const nested_exception&) throw() = default;
nested_exception& operator=(const nested_exception&) throw() = default;
virtual ~nested_exception() = default;
// access functions
void rethrow_nested [[noreturn]] () const;
exception_ptr nested_ptr() const;
};
template <class T> void throw_with_nested [[noreturn]] (T&& t);
template <class E> void rethrow_if_nested(const E& e);
} // std
*/
#include <__config>
#include <cstddef>
#pragma GCC system_header
namespace std // purposefully not using versioning namespace
{
class _LIBCPP_EXCEPTION_ABI exception
{
public:
_LIBCPP_INLINE_VISIBILITY exception() throw() {}
virtual ~exception() throw();
virtual const char* what() const throw();
};
class _LIBCPP_EXCEPTION_ABI bad_exception
: public exception
{
public:
_LIBCPP_INLINE_VISIBILITY bad_exception() throw() {}
virtual ~bad_exception() throw();
virtual const char* what() const throw();
};
typedef void (*unexpected_handler)();
_LIBCPP_VISIBLE unexpected_handler set_unexpected(unexpected_handler) throw();
_LIBCPP_VISIBLE void unexpected();
typedef void (*terminate_handler)();
_LIBCPP_VISIBLE terminate_handler set_terminate(terminate_handler) throw();
_LIBCPP_VISIBLE void terminate() __attribute__((__noreturn__));
_LIBCPP_VISIBLE bool uncaught_exception() throw();
class exception_ptr;
exception_ptr current_exception();
void rethrow_exception(exception_ptr); // noreturn
class exception_ptr
{
void* __ptr_;
public:
exception_ptr() : __ptr_() {}
exception_ptr(nullptr_t) : __ptr_() {}
exception_ptr(const exception_ptr&);
exception_ptr& operator=(const exception_ptr&);
~exception_ptr();
// explicit
operator bool() const {return __ptr_ != nullptr;}
friend bool operator==(const exception_ptr& __x, const exception_ptr& __y)
{return __x.__ptr_ == __y.__ptr_;}
friend bool operator!=(const exception_ptr& __x, const exception_ptr& __y)
{return !(__x == __y);}
friend exception_ptr current_exception();
friend void rethrow_exception(exception_ptr); // noreturn
};
template<class _E>
exception_ptr
make_exception_ptr(_E __e)
{
try
{
throw __e;
}
catch (...)
{
return current_exception();
}
}
} // std
#endif // _LIBCPP_EXCEPTION

908
libcxx/include/ext/hash_map Normal file
View File

@ -0,0 +1,908 @@
// -*- C++ -*-
//===-------------------------- hash_map ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_HASH_MAP
#define _LIBCPP_HASH_MAP
/*
hash_map synopsis
namespace __gnu_cxx
{
template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
class Alloc = allocator<pair<const Key, T>>>
class hash_map
{
public:
// types
typedef Key key_type;
typedef T mapped_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
explicit hash_map(size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_map(InputIterator f, InputIterator l,
size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
hash_map(const hash_map&);
~hash_map();
hash_map& operator=(const hash_map&);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
pair<iterator, bool> insert(const value_type& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(const_iterator position);
size_type erase(const key_type& k);
void erase(const_iterator first, const_iterator last);
void clear();
void swap(hash_map&);
hasher hash_funct() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
mapped_type& operator[](const key_type& k);
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type elems_in_bucket(size_type n) const;
void resize(size_type n);
};
template <class Key, class T, class Hash, class Pred, class Alloc>
void swap(hash_map<Key, T, Hash, Pred, Alloc>& x,
hash_map<Key, T, Hash, Pred, Alloc>& y);
template <class Key, class T, class Hash, class Pred, class Alloc>
bool
operator==(const hash_map<Key, T, Hash, Pred, Alloc>& x,
const hash_map<Key, T, Hash, Pred, Alloc>& y);
template <class Key, class T, class Hash, class Pred, class Alloc>
bool
operator!=(const hash_map<Key, T, Hash, Pred, Alloc>& x,
const hash_map<Key, T, Hash, Pred, Alloc>& y);
template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
class Alloc = allocator<pair<const Key, T>>>
class hash_multimap
{
public:
// types
typedef Key key_type;
typedef T mapped_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
explicit hash_multimap(size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_multimap(InputIterator f, InputIterator l,
size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit hash_multimap(const allocator_type&);
hash_multimap(const hash_multimap&);
~hash_multimap();
hash_multimap& operator=(const hash_multimap&);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
iterator insert(const value_type& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(const_iterator position);
size_type erase(const key_type& k);
void erase(const_iterator first, const_iterator last);
void clear();
void swap(hash_multimap&);
hasher hash_funct() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type elems_in_bucket(size_type n) const;
void resize(size_type n);
};
template <class Key, class T, class Hash, class Pred, class Alloc>
void swap(hash_multimap<Key, T, Hash, Pred, Alloc>& x,
hash_multimap<Key, T, Hash, Pred, Alloc>& y);
template <class Key, class T, class Hash, class Pred, class Alloc>
bool
operator==(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
template <class Key, class T, class Hash, class Pred, class Alloc>
bool
operator!=(const hash_multimap<Key, T, Hash, Pred, Alloc>& x,
const hash_multimap<Key, T, Hash, Pred, Alloc>& y);
} // __gnu_cxx
*/
#include <__config>
#include <__hash_table>
#include <functional>
#include <stdexcept>
#warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>
#pragma GCC system_header
namespace __gnu_cxx {
using namespace std;
template <class _Tp, class _Hash, bool = is_empty<_Hash>::value>
class __hash_map_hasher
: private _Hash
{
public:
__hash_map_hasher() : _Hash() {}
__hash_map_hasher(const _Hash& __h) : _Hash(__h) {}
const _Hash& hash_function() const {return *this;}
size_t operator()(const _Tp& __x) const
{return static_cast<const _Hash&>(*this)(__x.first);}
size_t operator()(const typename _Tp::first_type& __x) const
{return static_cast<const _Hash&>(*this)(__x);}
};
template <class _Tp, class _Hash>
class __hash_map_hasher<_Tp, _Hash, false>
{
_Hash __hash_;
public:
__hash_map_hasher() : __hash_() {}
__hash_map_hasher(const _Hash& __h) : __hash_(__h) {}
const _Hash& hash_function() const {return __hash_;}
size_t operator()(const _Tp& __x) const
{return __hash_(__x.first);}
size_t operator()(const typename _Tp::first_type& __x) const
{return __hash_(__x);}
};
template <class _Tp, class _Pred, bool = is_empty<_Pred>::value>
class __hash_map_equal
: private _Pred
{
public:
__hash_map_equal() : _Pred() {}
__hash_map_equal(const _Pred& __p) : _Pred(__p) {}
const _Pred& key_eq() const {return *this;}
bool operator()(const _Tp& __x, const _Tp& __y) const
{return static_cast<const _Pred&>(*this)(__x.first, __y.first);}
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
{return static_cast<const _Pred&>(*this)(__x, __y.first);}
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
{return static_cast<const _Pred&>(*this)(__x.first, __y);}
bool operator()(const typename _Tp::first_type& __x,
const typename _Tp::first_type& __y) const
{return static_cast<const _Pred&>(*this)(__x, __y);}
};
template <class _Tp, class _Pred>
class __hash_map_equal<_Tp, _Pred, false>
{
_Pred __pred_;
public:
__hash_map_equal() : __pred_() {}
__hash_map_equal(const _Pred& __p) : __pred_(__p) {}
const _Pred& key_eq() const {return __pred_;}
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __pred_(__x.first, __y.first);}
bool operator()(const typename _Tp::first_type& __x, const _Tp& __y) const
{return __pred_(__x, __y.first);}
bool operator()(const _Tp& __x, const typename _Tp::first_type& __y) const
{return __pred_(__x.first, __y);}
bool operator()(const typename _Tp::first_type& __x,
const typename _Tp::first_type& __y) const
{return __pred_(__x, __y);}
};
template <class _Alloc>
class __hash_map_node_destructor
{
typedef _Alloc allocator_type;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::value_type::value_type value_type;
public:
typedef typename __alloc_traits::pointer pointer;
private:
typedef typename value_type::first_type first_type;
typedef typename value_type::second_type second_type;
allocator_type& __na_;
__hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
public:
bool __first_constructed;
bool __second_constructed;
explicit __hash_map_node_destructor(allocator_type& __na)
: __na_(__na),
__first_constructed(false),
__second_constructed(false)
{}
#ifdef _LIBCPP_MOVE
__hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
: __na_(__x.__na_),
__first_constructed(__x.__value_constructed),
__second_constructed(__x.__value_constructed)
{
__x.__value_constructed = false;
}
#else
__hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
: __na_(__x.__na_),
__first_constructed(__x.__value_constructed),
__second_constructed(__x.__value_constructed)
{
const_cast<bool&>(__x.__value_constructed) = false;
}
#endif
void operator()(pointer __p)
{
if (__second_constructed)
__alloc_traits::destroy(__na_, addressof(__p->__value_.second));
if (__first_constructed)
__alloc_traits::destroy(__na_, addressof(__p->__value_.first));
if (__p)
__alloc_traits::deallocate(__na_, __p, 1);
}
};
template <class _HashIterator>
class __hash_map_iterator
{
_HashIterator __i_;
typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
typedef const typename _HashIterator::value_type::first_type key_type;
typedef typename _HashIterator::value_type::second_type mapped_type;
public:
typedef forward_iterator_tag iterator_category;
typedef pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef value_type& reference;
typedef typename __pointer_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind<value_type>
#else
rebind<value_type>::other
#endif
pointer;
__hash_map_iterator() {}
__hash_map_iterator(_HashIterator __i) : __i_(__i) {}
reference operator*() const {return *operator->();}
pointer operator->() const {return (pointer)__i_.operator->();}
__hash_map_iterator& operator++() {++__i_; return *this;}
__hash_map_iterator operator++(int)
{
__hash_map_iterator __t(*this);
++(*this);
return __t;
}
friend bool operator==(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ == __y.__i_;}
friend bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class hash_map;
template <class, class, class, class, class> friend class hash_multimap;
template <class> friend class __hash_const_iterator;
template <class> friend class __hash_const_local_iterator;
template <class> friend class __hash_map_const_iterator;
};
template <class _HashIterator>
class __hash_map_const_iterator
{
_HashIterator __i_;
typedef pointer_traits<typename _HashIterator::pointer> __pointer_traits;
typedef const typename _HashIterator::value_type::first_type key_type;
typedef typename _HashIterator::value_type::second_type mapped_type;
public:
typedef forward_iterator_tag iterator_category;
typedef pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef const value_type& reference;
typedef typename __pointer_traits::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind<value_type>
#else
rebind<value_type>::other
#endif
pointer;
__hash_map_const_iterator() {}
__hash_map_const_iterator(_HashIterator __i) : __i_(__i) {}
__hash_map_const_iterator(
__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i)
: __i_(__i.__i_) {}
reference operator*() const {return *operator->();}
pointer operator->() const {return (pointer)__i_.operator->();}
__hash_map_const_iterator& operator++() {++__i_; return *this;}
__hash_map_const_iterator operator++(int)
{
__hash_map_const_iterator __t(*this);
++(*this);
return __t;
}
friend bool operator==(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
{return __x.__i_ == __y.__i_;}
friend bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y)
{return __x.__i_ != __y.__i_;}
template <class, class, class, class, class> friend class hash_map;
template <class, class, class, class, class> friend class hash_multimap;
template <class> friend class __hash_const_iterator;
template <class> friend class __hash_const_local_iterator;
};
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > >
class hash_map
{
public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
__table __table_;
typedef typename __table::__node_pointer __node_pointer;
typedef typename __table::__node_const_pointer __node_const_pointer;
typedef typename __table::__node_traits __node_traits;
typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
typedef __hash_map_node_destructor<__node_allocator> _D;
typedef unique_ptr<__node, _D> __node_holder;
typedef allocator_traits<allocator_type> __alloc_traits;
public:
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
typedef typename __alloc_traits::size_type size_type;
typedef typename __alloc_traits::difference_type difference_type;
typedef __hash_map_iterator<typename __table::iterator> iterator;
typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
hash_map() {__table_.rehash(193);}
explicit hash_map(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
hash_map(size_type __n, const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
template <class _InputIterator>
hash_map(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
hash_map(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
hash_map(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
hash_map(const hash_map& __u);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void erase(const_iterator __p) {__table_.erase(__p.__i_);}
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
void erase(const_iterator __first, const_iterator __last)
{__table_.erase(__first.__i_, __last.__i_);}
void clear() {__table_.clear();}
void swap(hash_map& __u) {__table_.swap(__u.__table_);}
hasher hash_funct() const
{return __table_.hash_function().hash_function();}
key_equal key_eq() const
{return __table_.key_eq().key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
mapped_type& operator[](const key_type& __k);
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type elems_in_bucket(size_type __n) const
{return __table_.bucket_size(__n);}
void resize(size_type __n) {__table_.rehash(__n);}
private:
__node_holder __construct_node(const key_type& __k);
};
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
_InputIterator __first, _InputIterator __last)
{
__table_.rehash(193);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map(
const hash_map& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k)
{
__node_allocator& __na = __table_.__node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _D(__na));
__node_traits::construct(__na, addressof(__h->__value_.first), __k);
__h.get_deleter().__first_constructed = true;
__node_traits::construct(__na, addressof(__h->__value_.second));
__h.get_deleter().__second_constructed = true;
return _STD::move(__h);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_unique(*__first);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
_Tp&
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
{
iterator __i = find(__k);
if (__i != end())
return __i->second;
__node_holder __h = __construct_node(__k);
pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
__h.release();
return __r.first->second;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline
void
swap(hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
bool
operator==(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
__i != __ex; ++__i)
{
const_iterator __j = __y.find(__i->first);
if (__j == __ey || !(*__i == *__j))
return false;
}
return true;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
class _Alloc = allocator<pair<const _Key, _Tp> > >
class hash_multimap
{
public:
// types
typedef _Key key_type;
typedef _Tp mapped_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
typedef typename allocator_traits<allocator_type>::template
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
rebind_alloc<__value_type>
#else
rebind_alloc<__value_type>::other
#endif
__allocator_type;
typedef __hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
__table __table_;
typedef typename __table::__node_traits __node_traits;
typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
typedef __hash_map_node_destructor<__node_allocator> _D;
typedef unique_ptr<__node, _D> __node_holder;
typedef allocator_traits<allocator_type> __alloc_traits;
public:
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
typedef typename __alloc_traits::size_type size_type;
typedef typename __alloc_traits::difference_type difference_type;
typedef __hash_map_iterator<typename __table::iterator> iterator;
typedef __hash_map_const_iterator<typename __table::const_iterator> const_iterator;
hash_multimap() {__table_.rehash(193);}
explicit hash_multimap(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
hash_multimap(size_type __n, const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
template <class _InputIterator>
hash_multimap(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
hash_multimap(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
hash_multimap(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf,
const key_equal& __eql,
const allocator_type& __a);
hash_multimap(const hash_multimap& __u);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void erase(const_iterator __p) {__table_.erase(__p.__i_);}
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
void erase(const_iterator __first, const_iterator __last)
{__table_.erase(__first.__i_, __last.__i_);}
void clear() {__table_.clear();}
void swap(hash_multimap& __u) {__table_.swap(__u.__table_);}
hasher hash_funct() const
{return __table_.hash_function().hash_function();}
key_equal key_eq() const
{return __table_.key_eq().key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type elems_in_bucket(size_type __n) const
{return __table_.bucket_size(__n);}
void resize(size_type __n) {__table_.rehash(__n);}
};
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
_InputIterator __first, _InputIterator __last)
{
__table_.rehash(193);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap(
const hash_multimap& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_multi(*__first);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline
void
swap(hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
bool
operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
typedef pair<const_iterator, const_iterator> _EqRng;
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
{
_EqRng __xeq = __x.equal_range(__i->first);
_EqRng __yeq = __y.equal_range(__i->first);
if (_STD::distance(__xeq.first, __xeq.second) !=
_STD::distance(__yeq.first, __yeq.second) ||
!_STD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
return false;
__i = __xeq.second;
}
return true;
}
template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
} // __gnu_cxx
#endif // _LIBCPP_HASH_MAP

598
libcxx/include/ext/hash_set Normal file
View File

@ -0,0 +1,598 @@
// -*- C++ -*-
//===------------------------- hash_set ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_HASH_SET
#define _LIBCPP_HASH_SET
/*
hash_set synopsis
namespace __gnu_cxx
{
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
class Alloc = allocator<Value>>
class hash_set
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
explicit hash_set(size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_set(InputIterator f, InputIterator l,
size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
hash_set(const hash_set&);
~hash_set();
hash_set& operator=(const hash_set&);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
pair<iterator, bool> insert(const value_type& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(const_iterator position);
size_type erase(const key_type& k);
void erase(const_iterator first, const_iterator last);
void clear();
void swap(hash_set&);
hasher hash_funct() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type elems_in_bucket(size_type n) const;
void resize(size_type n);
};
template <class Value, class Hash, class Pred, class Alloc>
void swap(hash_set<Value, Hash, Pred, Alloc>& x,
hash_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator==(const hash_set<Value, Hash, Pred, Alloc>& x,
const hash_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator!=(const hash_set<Value, Hash, Pred, Alloc>& x,
const hash_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
class Alloc = allocator<Value>>
class hash_multiset
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
explicit hash_multiset(size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
hash_multiset(InputIterator f, InputIterator l,
size_type n = 193, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
hash_multiset(const hash_multiset&);
~hash_multiset();
hash_multiset& operator=(const hash_multiset&);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
iterator insert(const value_type& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(const_iterator position);
size_type erase(const key_type& k);
void erase(const_iterator first, const_iterator last);
void clear();
void swap(hash_multiset&);
hasher hash_funct() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type elems_in_bucket(size_type n) const;
void resize(size_type n);
};
template <class Value, class Hash, class Pred, class Alloc>
void swap(hash_multiset<Value, Hash, Pred, Alloc>& x,
hash_multiset<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator==(const hash_multiset<Value, Hash, Pred, Alloc>& x,
const hash_multiset<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator!=(const hash_multiset<Value, Hash, Pred, Alloc>& x,
const hash_multiset<Value, Hash, Pred, Alloc>& y);
} // __gnu_cxx
*/
#include <__config>
#include <__hash_table>
#include <functional>
#warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>
namespace __gnu_cxx {
using namespace std;
template <class _Value, class _Hash = std::hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class hash_set
{
public:
// types
typedef _Value key_type;
typedef key_type value_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
typedef typename __table::pointer pointer;
typedef typename __table::const_pointer const_pointer;
typedef typename __table::size_type size_type;
typedef typename __table::difference_type difference_type;
typedef typename __table::const_iterator iterator;
typedef typename __table::const_iterator const_iterator;
hash_set() {__table_.rehash(193);}
explicit hash_set(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
hash_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
template <class _InputIterator>
hash_set(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
hash_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
hash_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
hash_set(const hash_set& __u);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void erase(const_iterator __p) {__table_.erase(__p);}
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
void erase(const_iterator __first, const_iterator __last)
{__table_.erase(__first, __last);}
void clear() {__table_.clear();}
void swap(hash_set& __u) {__table_.swap(__u.__table_);}
hasher hash_funct() const {return __table_.hash_function();}
key_equal key_eq() const {return __table_.key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
void resize(size_type __n) {__table_.rehash(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
_InputIterator __first, _InputIterator __last)
{
__table_.rehash(193);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(
const hash_set& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_unique(*__first);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
void
swap(hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename hash_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
__i != __ex; ++__i)
{
const_iterator __j = __y.find(*__i);
if (__j == __ey || !(*__i == *__j))
return false;
}
return true;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class hash_multiset
{
public:
// types
typedef _Value key_type;
typedef key_type value_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
typedef typename __table::pointer pointer;
typedef typename __table::const_pointer const_pointer;
typedef typename __table::size_type size_type;
typedef typename __table::difference_type difference_type;
typedef typename __table::const_iterator iterator;
typedef typename __table::const_iterator const_iterator;
hash_multiset() {__table_.rehash(193);}
explicit hash_multiset(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
hash_multiset(size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a);
template <class _InputIterator>
hash_multiset(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
hash_multiset(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
hash_multiset(_InputIterator __first, _InputIterator __last,
size_type __n , const hasher& __hf,
const key_equal& __eql, const allocator_type& __a);
hash_multiset(const hash_multiset& __u);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void erase(const_iterator __p) {__table_.erase(__p);}
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
void erase(const_iterator __first, const_iterator __last)
{__table_.erase(__first, __last);}
void clear() {__table_.clear();}
void swap(hash_multiset& __u) {__table_.swap(__u.__table_);}
hasher hash_funct() const {return __table_.hash_function();}
key_equal key_eq() const {return __table_.key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);}
void resize(size_type __n) {__table_.rehash(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
_InputIterator __first, _InputIterator __last)
{
__table_.rehash(193);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset(
const hash_multiset& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_multi(*__first);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
void
swap(hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename hash_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
typedef pair<const_iterator, const_iterator> _EqRng;
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
{
_EqRng __xeq = __x.equal_range(*__i);
_EqRng __yeq = __y.equal_range(*__i);
if (_STD::distance(__xeq.first, __xeq.second) !=
_STD::distance(__yeq.first, __yeq.second) ||
!_STD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
return false;
__i = __xeq.second;
}
return true;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
} // __gnu_cxx
#endif // _LIBCPP_HASH_SET

1458
libcxx/include/forward_list Normal file

File diff suppressed because it is too large Load Diff

1394
libcxx/include/fstream Normal file

File diff suppressed because it is too large Load Diff

1850
libcxx/include/functional Normal file

File diff suppressed because it is too large Load Diff

500
libcxx/include/future Normal file
View File

@ -0,0 +1,500 @@
// -*- C++ -*-
//===--------------------------- future -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_FUTURE
#define _LIBCPP_FUTURE
/*
future synopsis
namespace std
{
enum class future_errc
{
broken_promise,
future_already_retrieved,
promise_already_satisfied,
no_state
};
enum class launch
{
any,
async,
sync
};
enum class future_status
{
ready,
timeout,
deferred
};
template <> struct is_error_code_enum<future_errc> : public true_type { };
error_code make_error_code(future_errc e);
error_condition make_error_condition(future_errc e);
const error_category& future_category();
class future_error
: public logic_error
{
public:
future_error(error_code ec); // exposition only
const error_code& code() const throw();
const char* what() const throw();
};
template <class R>
class promise
{
public:
promise();
template <class Allocator>
promise(allocator_arg_t, const Allocator& a);
promise(promise&& rhs);
promise(const promise& rhs) = delete;
~promise();
// assignment
promise& operator=(promise&& rhs);
promise& operator=(const promise& rhs) = delete;
void swap(promise& other);
// retrieving the result
future<R> get_future();
// setting the result
void set_value(const R& r);
void set_value(R&& r);
void set_exception(exception_ptr p);
// setting the result with deferred notification
void set_value_at_thread_exit(const R& r);
void set_value_at_thread_exit(R&& r);
void set_exception_at_thread_exit(exception_ptr p);
};
template <class R>
class promise<R&>
{
public:
promise();
template <class Allocator>
promise(allocator_arg_t, const Allocator& a);
promise(promise&& rhs);
promise(const promise& rhs) = delete;
~promise();
// assignment
promise& operator=(promise&& rhs);
promise& operator=(const promise& rhs) = delete;
void swap(promise& other);
// retrieving the result
future<R> get_future();
// setting the result
void set_value(R& r);
void set_exception(exception_ptr p);
// setting the result with deferred notification
void set_value_at_thread_exit(R&);
void set_exception_at_thread_exit(exception_ptr p);
};
template <>
class promise<void>
{
public:
promise();
template <class Allocator>
promise(allocator_arg_t, const Allocator& a);
promise(promise&& rhs);
promise(const promise& rhs) = delete;
~promise();
// assignment
promise& operator=(promise&& rhs);
promise& operator=(const promise& rhs) = delete;
void swap(promise& other);
// retrieving the result
future<R> get_future();
// setting the result
void set_value();
void set_exception(exception_ptr p);
// setting the result with deferred notification
void set_value_at_thread_exit();
void set_exception_at_thread_exit(exception_ptr p);
};
template <class R> void swap(promise<R>& x, promise<R>& y);
template <class R, class Alloc>
struct uses_allocator<promise<R>, Alloc> : public true_type {};
template <class R>
class future
{
public:
future();
future(future&&);
future(const future& rhs) = delete;
~future();
future& operator=(const future& rhs) = delete;
future& operator=(future&&);
// retrieving the value
R get();
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class R>
class future<R&>
{
public:
future();
future(future&&);
future(const future& rhs) = delete;
~future();
future& operator=(const future& rhs) = delete;
future& operator=(future&&);
// retrieving the value
R& get();
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <>
class future<void>
{
public:
future();
future(future&&);
future(const future& rhs) = delete;
~future();
future& operator=(const future& rhs) = delete;
future& operator=(future&&);
// retrieving the value
void get();
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class R>
class shared_future
{
public:
shared_future();
shared_future(const shared_future& rhs);
shared_future(future<R>&&);
shared_future(shared_future&& rhs);
~shared_future();
shared_future& operator=(const shared_future& rhs);
shared_future& operator=(shared_future&& rhs);
// retrieving the value
const R& get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class R>
class shared_future<R&>
{
public:
shared_future();
shared_future(const shared_future& rhs);
shared_future(future<R>&&);
shared_future(shared_future&& rhs);
~shared_future();
shared_future& operator=(const shared_future& rhs);
shared_future& operator=(shared_future&& rhs);
// retrieving the value
R& get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <>
class shared_future<void>
{
public:
shared_future();
shared_future(const shared_future& rhs);
shared_future(future<R>&&);
shared_future(shared_future&& rhs);
~shared_future();
shared_future& operator=(const shared_future& rhs);
shared_future& operator=(shared_future&& rhs);
// retrieving the value
void get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class R>
class atomic_future
{
public:
atomic_future();
atomic_future(const atomic_future& rhs);
atomic_future(future<R>&&);
~atomic_future();
atomic_future& operator=(const atomic_future& rhs);
// retrieving the value
const R& get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class R>
class atomic_future<R&>
{
public:
atomic_future();
atomic_future(const atomic_future& rhs);
atomic_future(future<R>&&);
~atomic_future();
atomic_future& operator=(const atomic_future& rhs);
// retrieving the value
R& get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <>
class atomic_future<void>
{
public:
atomic_future();
atomic_future(const atomic_future& rhs);
atomic_future(future<R>&&);
~atomic_future();
atomic_future& operator=(const atomic_future& rhs);
// retrieving the value
void get() const;
// functions to check state
bool valid() const;
void wait() const;
template <class Rep, class Period>
future_status
wait_for(const chrono::duration<Rep, Period>& rel_time) const;
template <class Clock, class Duration>
future_status
wait_until(const chrono::time_point<Clock, Duration>& abs_time) const;
};
template <class F, class... Args>
future<typename result_of<F(Args...)>::type>
async(F&& f, Args&&... args);
template <class F, class... Args>
future<typename result_of<F(Args...)>::type>
async(launch policy, F&& f, Args&&... args);
template <class> class packaged_task; // undefined
template <class R, class... ArgTypes>
class packaged_task<R(ArgTypes...)>
{
public:
typedef R result_type;
// construction and destruction
packaged_task();
template <class F>
explicit packaged_task(F f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F f);
explicit packaged_task(R(*f)(ArgTypes...));
template <class F>
explicit packaged_task(F&& f);
template <class F, class Allocator>
explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
~packaged_task();
// no copy
packaged_task(packaged_task&) = delete;
packaged_task& operator=(packaged_task&) = delete;
// move support
packaged_task(packaged_task&& other);
packaged_task& operator=(packaged_task&& other);
void swap(packaged_task& other);
explicit operator bool() const;
// result retrieval
future<R> get_future();
// execution
void operator()(ArgTypes... );
void make_ready_at_thread_exit(ArgTypes...);
void reset();
};
template <class R>
void swap(packaged_task<R(ArgTypes...)&, packaged_task<R(ArgTypes...)>&);
template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
} // std
*/
#include <__config>
#include <system_error>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
//enum class future_errc
struct future_errc
{
enum _ {
broken_promise,
future_already_retrieved,
promise_already_satisfied,
no_state
};
_ __v_;
future_errc(_ __v) : __v_(__v) {}
operator int() const {return __v_;}
};
//enum class launch
struct launch
{
enum _ {
any,
async,
sync
};
_ __v_;
launch(_ __v) : __v_(__v) {}
operator int() const {return __v_;}
};
//enum class future_status
struct future_status
{
enum _ {
ready,
timeout,
deferred
};
_ __v_;
future_status(_ __v) : __v_(__v) {}
operator int() const {return __v_;}
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_FUTURE

View File

@ -0,0 +1,80 @@
// -*- C++ -*-
//===----------------------- initializer_list -----------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_INITIALIZER_LIST
#define _LIBCPP_INITIALIZER_LIST
/*
initializer_list synopsis
namespace std
{
template<class E>
class initializer_list
{
public:
typedef E value_type;
typedef const E& reference;
typedef const E& const_reference;
typedef size_t size_type;
typedef const E* iterator;
typedef const E* const_iterator;
initializer_list();
size_t size() const;
const E* begin() const;
const E* end() const;
};
} // std
*/
#include <__config>
#include <cstddef>
#pragma GCC system_header
namespace std // purposefully not versioned
{
template<class _E>
class initializer_list
{
const _E* __begin_;
size_t __size_;
_LIBCPP_ALWAYS_INLINE
initializer_list(const _E* __b, size_t __s)
: __begin_(__b),
__size_(__s)
{}
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
_LIBCPP_ALWAYS_INLINE initializer_list() : __begin_(nullptr), __size_(0) {}
_LIBCPP_ALWAYS_INLINE size_t size() const {return __size_;}
_LIBCPP_ALWAYS_INLINE const _E* begin() const {return __begin_;}
_LIBCPP_ALWAYS_INLINE const _E* end() const {return __begin_ + __size_;}
};
} // std
#endif // _LIBCPP_INITIALIZER_LIST

481
libcxx/include/iomanip Normal file
View File

@ -0,0 +1,481 @@
// -*- C++ -*-
//===--------------------------- iomanip ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_IOMANIP
#define _LIBCPP_IOMANIP
/*
iomanip synopsis
// types T1, T2, ... are unspecified implementation types
T1 resetiosflags(ios_base::fmtflags mask);
T2 setiosflags (ios_base::fmtflags mask);
T3 setbase(int base);
template<charT> T4 setfill(charT c);
T5 setprecision(int n);
T6 setw(int n);
template <class moneyT> T7 get_money(moneyT& mon, bool intl = false);
template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = false);
template <class charT> T9 get_time(struct tm* tmb, const charT* fmt);
template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt);
} // std
*/
#include <__config>
#include <istream>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
// resetiosflags
class __iom_t1
{
ios_base::fmtflags __mask_;
public:
explicit __iom_t1(ios_base::fmtflags __m) : __mask_(__m) {}
template <class _CharT, class _Traits>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t1& __x)
{
__is.unsetf(__x.__mask_);
return __is;
}
template <class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t1& __x)
{
__os.unsetf(__x.__mask_);
return __os;
}
};
inline _LIBCPP_INLINE_VISIBILITY
__iom_t1
resetiosflags(ios_base::fmtflags __mask)
{
return __iom_t1(__mask);
}
// setiosflags
class __iom_t2
{
ios_base::fmtflags __mask_;
public:
explicit __iom_t2(ios_base::fmtflags __m) : __mask_(__m) {}
template <class _CharT, class _Traits>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t2& __x)
{
__is.setf(__x.__mask_);
return __is;
}
template <class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t2& __x)
{
__os.setf(__x.__mask_);
return __os;
}
};
inline _LIBCPP_INLINE_VISIBILITY
__iom_t2
setiosflags(ios_base::fmtflags __mask)
{
return __iom_t2(__mask);
}
// setbase
class __iom_t3
{
int __base_;
public:
explicit __iom_t3(int __b) : __base_(__b) {}
template <class _CharT, class _Traits>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t3& __x)
{
__is.setf(__x.__base_ == 8 ? ios_base::oct :
__x.__base_ == 10 ? ios_base::dec :
__x.__base_ == 16 ? ios_base::hex :
ios_base::fmtflags(0), ios_base::basefield);
return __is;
}
template <class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t3& __x)
{
__os.setf(__x.__base_ == 8 ? ios_base::oct :
__x.__base_ == 10 ? ios_base::dec :
__x.__base_ == 16 ? ios_base::hex :
ios_base::fmtflags(0), ios_base::basefield);
return __os;
}
};
inline _LIBCPP_INLINE_VISIBILITY
__iom_t3
setbase(int __base)
{
return __iom_t3(__base);
}
// setfill
template<class _CharT>
class __iom_t4
{
_CharT __fill_;
public:
explicit __iom_t4(_CharT __c) : __fill_(__c) {}
template <class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t4& __x)
{
__os.fill(__x.__fill_);
return __os;
}
};
template<class _CharT>
inline _LIBCPP_INLINE_VISIBILITY
__iom_t4<_CharT>
setfill(_CharT __c)
{
return __iom_t4<_CharT>(__c);
}
// setprecision
class __iom_t5
{
int __n_;
public:
explicit __iom_t5(int __n) : __n_(__n) {}
template <class _CharT, class _Traits>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t5& __x)
{
__is.precision(__x.__n_);
return __is;
}
template <class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t5& __x)
{
__os.precision(__x.__n_);
return __os;
}
};
inline _LIBCPP_INLINE_VISIBILITY
__iom_t5
setprecision(int __n)
{
return __iom_t5(__n);
}
// setw
class __iom_t6
{
int __n_;
public:
explicit __iom_t6(int __n) : __n_(__n) {}
template <class _CharT, class _Traits>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t6& __x)
{
__is.width(__x.__n_);
return __is;
}
template <class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t6& __x)
{
__os.width(__x.__n_);
return __os;
}
};
inline _LIBCPP_INLINE_VISIBILITY
__iom_t6
setw(int __n)
{
return __iom_t6(__n);
}
// get_money
template <class _MoneyT> class __iom_t7;
template <class _CharT, class _Traits, class _MoneyT>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x);
template <class _MoneyT>
class __iom_t7
{
_MoneyT& __mon_;
bool __intl_;
public:
__iom_t7(_MoneyT& __mon, bool __intl)
: __mon_(__mon), __intl_(__intl) {}
template <class _CharT, class _Traits, class _M>
friend
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_M>& __x);
};
template <class _CharT, class _Traits, class _MoneyT>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
typedef istreambuf_iterator<_CharT, _Traits> _I;
typedef money_get<_CharT, _I> _F;
ios_base::iostate __err = ios_base::goodbit;
const _F& __mf = use_facet<_F>(__is.getloc());
__mf.get(_I(__is), _I(), __x.__intl_, __is, __err, __x.__mon_);
__is.setstate(__err);
}
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__is.__set_badbit_and_consider_rethrow();
}
#endif
return __is;
}
template <class _MoneyT>
inline _LIBCPP_INLINE_VISIBILITY
__iom_t7<_MoneyT>
get_money(_MoneyT& __mon, bool __intl = false)
{
return __iom_t7<_MoneyT>(__mon, __intl);
}
// put_money
template <class _MoneyT> class __iom_t8;
template <class _CharT, class _Traits, class _MoneyT>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x);
template <class _MoneyT>
class __iom_t8
{
const _MoneyT& __mon_;
bool __intl_;
public:
__iom_t8(const _MoneyT& __mon, bool __intl)
: __mon_(__mon), __intl_(__intl) {}
template <class _CharT, class _Traits, class _M>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_M>& __x);
};
template <class _CharT, class _Traits, class _MoneyT>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
typedef ostreambuf_iterator<_CharT, _Traits> _O;
typedef money_put<_CharT, _O> _F;
const _F& __mf = use_facet<_F>(__os.getloc());
if (__mf.put(_O(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
__os.setstate(ios_base::badbit);
}
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__os.__set_badbit_and_consider_rethrow();
}
#endif
return __os;
}
template <class _MoneyT>
inline _LIBCPP_INLINE_VISIBILITY
__iom_t8<_MoneyT>
put_money(const _MoneyT& __mon, bool __intl = false)
{
return __iom_t8<_MoneyT>(__mon, __intl);
}
// get_time
template <class _CharT> class __iom_t9;
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x);
template <class _CharT>
class __iom_t9
{
tm* __tm_;
const _CharT* __fmt_;
public:
__iom_t9(tm* __tm, const _CharT* __fmt)
: __tm_(__tm), __fmt_(__fmt) {}
template <class _C, class _Traits>
friend
basic_istream<_C, _Traits>&
operator>>(basic_istream<_C, _Traits>& __is, const __iom_t9<_C>& __x);
};
template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s)
{
typedef istreambuf_iterator<_CharT, _Traits> _I;
typedef time_get<_CharT, _I> _F;
ios_base::iostate __err = ios_base::goodbit;
const _F& __tf = use_facet<_F>(__is.getloc());
__tf.get(_I(__is), _I(), __is, __err, __x.__tm_,
__x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
__is.setstate(__err);
}
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__is.__set_badbit_and_consider_rethrow();
}
#endif
return __is;
}
template <class _CharT>
inline _LIBCPP_INLINE_VISIBILITY
__iom_t9<_CharT>
get_time(tm* __tm, const _CharT* __fmt)
{
return __iom_t9<_CharT>(__tm, __fmt);
}
// put_time
template <class _CharT> class __iom_t10;
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x);
template <class _CharT>
class __iom_t10
{
const tm* __tm_;
const _CharT* __fmt_;
public:
__iom_t10(const tm* __tm, const _CharT* __fmt)
: __tm_(__tm), __fmt_(__fmt) {}
template <class _C, class _Traits>
friend
basic_ostream<_C, _Traits>&
operator<<(basic_ostream<_C, _Traits>& __os, const __iom_t10<_C>& __x);
};
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s)
{
typedef ostreambuf_iterator<_CharT, _Traits> _O;
typedef time_put<_CharT, _O> _F;
const _F& __tf = use_facet<_F>(__os.getloc());
if (__tf.put(_O(__os), __os, __os.fill(), __x.__tm_,
__x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)).failed())
__os.setstate(ios_base::badbit);
}
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
__os.__set_badbit_and_consider_rethrow();
}
#endif
return __os;
}
template <class _CharT>
inline _LIBCPP_INLINE_VISIBILITY
__iom_t10<_CharT>
put_time(const tm* __tm, const _CharT* __fmt)
{
return __iom_t10<_CharT>(__tm, __fmt);
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOMANIP

965
libcxx/include/ios Normal file
View File

@ -0,0 +1,965 @@
// -*- C++ -*-
//===---------------------------- ios -------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_IOS
#define _LIBCPP_IOS
/*
ios synopsis
#include <iosfwd>
namespace std
{
typedef OFF_T streamoff;
typedef SZ_T streamsize;
template <class stateT> class fpos;
class ios_base
{
public:
class failure;
typedef T1 fmtflags;
static const fmtflags boolalpha;
static const fmtflags dec;
static const fmtflags fixed;
static const fmtflags hex;
static const fmtflags internal;
static const fmtflags left;
static const fmtflags oct;
static const fmtflags right;
static const fmtflags scientific;
static const fmtflags showbase;
static const fmtflags showpoint;
static const fmtflags showpos;
static const fmtflags skipws;
static const fmtflags unitbuf;
static const fmtflags uppercase;
static const fmtflags adjustfield;
static const fmtflags basefield;
static const fmtflags floatfield;
typedef T2 iostate;
static const iostate badbit;
static const iostate eofbit;
static const iostate failbit;
static const iostate goodbit;
typedef T3 openmode;
static const openmode app;
static const openmode ate;
static const openmode binary;
static const openmode in;
static const openmode out;
static const openmode trunc;
typedef T4 seekdir;
static const seekdir beg;
static const seekdir cur;
static const seekdir end;
class Init;
// 27.5.2.2 fmtflags state:
fmtflags flags() const;
fmtflags flags(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl);
fmtflags setf(fmtflags fmtfl, fmtflags mask);
void unsetf(fmtflags mask);
streamsize precision() const;
streamsize precision(streamsize prec);
streamsize width() const;
streamsize width(streamsize wide);
// 27.5.2.3 locales:
locale imbue(const locale& loc);
locale getloc() const;
// 27.5.2.5 storage:
static int xalloc();
long& iword(int index);
void*& pword(int index);
// destructor
virtual ~ios_base();
// 27.5.2.6 callbacks;
enum event { erase_event, imbue_event, copyfmt_event };
typedef void (*event_callback)(event, ios_base&, int index);
void register_callback(event_callback fn, int index);
ios_base(const ios_base&) = delete;
ios_base& operator=(const ios_base&) = delete;
static bool sync_with_stdio(bool sync = true);
protected:
ios_base();
};
template <class charT, class traits = char_traits<charT> >
class basic_ios
: public ios_base
{
public:
// types:
typedef charT char_type;
typedef typename traits::int_type int_type;
typedef typename traits::pos_type pos_type;
typedef typename traits::off_type off_type;
typedef traits traits_type;
operator unspecified-bool-type() const;
bool operator!() const;
iostate rdstate() const;
void clear(iostate state = goodbit);
void setstate(iostate state);
bool good() const;
bool eof() const;
bool fail() const;
bool bad() const;
iostate exceptions() const;
void exceptions(iostate except);
// 27.5.4.1 Constructor/destructor:
explicit basic_ios(basic_streambuf<charT,traits>* sb);
virtual ~basic_ios();
// 27.5.4.2 Members:
basic_ostream<charT,traits>* tie() const;
basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
basic_streambuf<charT,traits>* rdbuf() const;
basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
basic_ios& copyfmt(const basic_ios& rhs);
char_type fill() const;
char_type fill(char_type ch);
locale imbue(const locale& loc);
char narrow(char_type c, char dfault) const;
char_type widen(char c) const;
basic_ios(const basic_ios& ) = delete;
basic_ios& operator=(const basic_ios&) = delete;
protected:
basic_ios();
void init(basic_streambuf<charT,traits>* sb);
void move(basic_ios& rhs);
void swap(basic_ios& rhs);
void set_rdbuf(basic_streambuf<charT, traits>* sb);
};
// 27.5.5, manipulators:
ios_base& boolalpha (ios_base& str);
ios_base& noboolalpha(ios_base& str);
ios_base& showbase (ios_base& str);
ios_base& noshowbase (ios_base& str);
ios_base& showpoint (ios_base& str);
ios_base& noshowpoint(ios_base& str);
ios_base& showpos (ios_base& str);
ios_base& noshowpos (ios_base& str);
ios_base& skipws (ios_base& str);
ios_base& noskipws (ios_base& str);
ios_base& uppercase (ios_base& str);
ios_base& nouppercase(ios_base& str);
ios_base& unitbuf (ios_base& str);
ios_base& nounitbuf (ios_base& str);
// 27.5.5.2 adjustfield:
ios_base& internal (ios_base& str);
ios_base& left (ios_base& str);
ios_base& right (ios_base& str);
// 27.5.5.3 basefield:
ios_base& dec (ios_base& str);
ios_base& hex (ios_base& str);
ios_base& oct (ios_base& str);
// 27.5.5.4 floatfield:
ios_base& fixed (ios_base& str);
ios_base& scientific (ios_base& str);
ios_base& hexfloat (ios_base& str);
ios_base& defaultfloat(ios_base& str);
// 27.5.5.5 error reporting:
enum class io_errc
{
stream = 1
};
concept_map ErrorCodeEnum<io_errc> { };
error_code make_error_code(io_errc e);
error_condition make_error_condition(io_errc e);
storage-class-specifier const error_category& iostream_category;
} // std
*/
#include <__config>
#include <iosfwd>
#include <__locale>
#include <system_error>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
typedef ptrdiff_t streamsize;
class ios_base
{
public:
class failure;
typedef unsigned int fmtflags;
static const fmtflags boolalpha = 0x0001;
static const fmtflags dec = 0x0002;
static const fmtflags fixed = 0x0004;
static const fmtflags hex = 0x0008;
static const fmtflags internal = 0x0010;
static const fmtflags left = 0x0020;
static const fmtflags oct = 0x0040;
static const fmtflags right = 0x0080;
static const fmtflags scientific = 0x0100;
static const fmtflags showbase = 0x0200;
static const fmtflags showpoint = 0x0400;
static const fmtflags showpos = 0x0800;
static const fmtflags skipws = 0x1000;
static const fmtflags unitbuf = 0x2000;
static const fmtflags uppercase = 0x4000;
static const fmtflags adjustfield = left | right | internal;
static const fmtflags basefield = dec | oct | hex;
static const fmtflags floatfield = scientific | fixed;
typedef unsigned int iostate;
typedef iostate io_state;
static const iostate badbit = 0x1;
static const iostate eofbit = 0x2;
static const iostate failbit = 0x4;
static const iostate goodbit = 0x0;
typedef unsigned int openmode;
typedef openmode open_mode;
static const openmode app = 0x01;
static const openmode ate = 0x02;
static const openmode binary = 0x04;
static const openmode in = 0x08;
static const openmode out = 0x10;
static const openmode trunc = 0x20;
enum seekdir {beg, cur, end};
typedef seekdir seek_dir;
typedef _STD::streamoff streamoff;
typedef _STD::streampos streampos;
class Init;
// 27.5.2.2 fmtflags state:
fmtflags flags() const;
fmtflags flags(fmtflags __fmtfl);
fmtflags setf(fmtflags __fmtfl);
fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
void unsetf(fmtflags __mask);
streamsize precision() const;
streamsize precision(streamsize __prec);
streamsize width() const;
streamsize width(streamsize __wide);
// 27.5.2.3 locales:
locale imbue(const locale& __loc);
locale getloc() const;
// 27.5.2.5 storage:
static int xalloc();
long& iword(int __index);
void*& pword(int __index);
// destructor
virtual ~ios_base();
// 27.5.2.6 callbacks;
enum event { erase_event, imbue_event, copyfmt_event };
typedef void (*event_callback)(event, ios_base&, int __index);
void register_callback(event_callback __fn, int __index);
private:
ios_base(const ios_base&); // = delete;
ios_base& operator=(const ios_base&); // = delete;
public:
static bool sync_with_stdio(bool __sync = true);
iostate rdstate() const;
void clear(iostate __state = goodbit);
void setstate(iostate __state);
bool good() const;
bool eof() const;
bool fail() const;
bool bad() const;
iostate exceptions() const;
void exceptions(iostate __except);
void __set_badbit_and_consider_rethrow();
void __set_failbit_and_consider_rethrow();
protected:
ios_base() {// purposefully does no initialization
}
void init(void* __sb);
_LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;}
_LIBCPP_ALWAYS_INLINE
void rdbuf(void* __sb)
{
__rdbuf_ = __sb;
clear();
}
void __call_callbacks(event);
void copyfmt(const ios_base&);
void move(ios_base&);
void swap(ios_base&);
_LIBCPP_ALWAYS_INLINE
void set_rdbuf(void* __sb)
{
__rdbuf_ = __sb;
}
private:
// All data members must be scalars
fmtflags __fmtflags_;
streamsize __precision_;
streamsize __width_;
iostate __rdstate_;
iostate __exceptions_;
void* __rdbuf_;
void* __loc_;
event_callback* __fn_;
int* __index_;
size_t __event_size_;
size_t __event_cap_;
static int __xindex_;
long* __iarray_;
size_t __iarray_size_;
size_t __iarray_cap_;
void** __parray_;
size_t __parray_size_;
size_t __parray_cap_;
};
//enum class io_errc
struct io_errc
{
enum _ {
stream = 1
};
_ __v_;
_LIBCPP_ALWAYS_INLINE io_errc(_ __v) : __v_(__v) {}
_LIBCPP_ALWAYS_INLINE operator int() const {return __v_;}
};
template <> struct is_error_code_enum<io_errc> : public true_type { };
template <> struct is_error_code_enum<io_errc::_> : public true_type { };
const error_category& iostream_category();
inline _LIBCPP_INLINE_VISIBILITY
error_code
make_error_code(io_errc __e)
{
return error_code(static_cast<int>(__e), iostream_category());
}
inline _LIBCPP_INLINE_VISIBILITY
error_condition
make_error_condition(io_errc __e)
{
return error_condition(static_cast<int>(__e), iostream_category());
}
class ios_base::failure
: public system_error
{
public:
explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
virtual ~failure() throw();
};
class ios_base::Init
{
public:
Init();
~Init();
};
// fmtflags
inline _LIBCPP_INLINE_VISIBILITY
ios_base::fmtflags
ios_base::flags() const
{
return __fmtflags_;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base::fmtflags
ios_base::flags(fmtflags __fmtfl)
{
fmtflags __r = __fmtflags_;
__fmtflags_ = __fmtfl;
return __r;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base::fmtflags
ios_base::setf(fmtflags __fmtfl)
{
fmtflags __r = __fmtflags_;
__fmtflags_ |= __fmtfl;
return __r;
}
inline _LIBCPP_INLINE_VISIBILITY
void
ios_base::unsetf(fmtflags __mask)
{
__fmtflags_ &= ~__mask;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base::fmtflags
ios_base::setf(fmtflags __fmtfl, fmtflags __mask)
{
fmtflags __r = __fmtflags_;
unsetf(__mask);
__fmtflags_ |= __fmtfl & __mask;
return __r;
}
// precision
inline _LIBCPP_INLINE_VISIBILITY
streamsize
ios_base::precision() const
{
return __precision_;
}
inline _LIBCPP_INLINE_VISIBILITY
streamsize
ios_base::precision(streamsize __prec)
{
streamsize __r = __precision_;
__precision_ = __prec;
return __r;
}
// width
inline _LIBCPP_INLINE_VISIBILITY
streamsize
ios_base::width() const
{
return __width_;
}
inline _LIBCPP_INLINE_VISIBILITY
streamsize
ios_base::width(streamsize __wide)
{
streamsize __r = __width_;
__width_ = __wide;
return __r;
}
// iostate
inline _LIBCPP_INLINE_VISIBILITY
ios_base::iostate
ios_base::rdstate() const
{
return __rdstate_;
}
inline _LIBCPP_INLINE_VISIBILITY
void
ios_base::setstate(iostate __state)
{
clear(__rdstate_ | __state);
}
inline _LIBCPP_INLINE_VISIBILITY
bool
ios_base::good() const
{
return __rdstate_ == 0;
}
inline _LIBCPP_INLINE_VISIBILITY
bool
ios_base::eof() const
{
return __rdstate_ & eofbit;
}
inline _LIBCPP_INLINE_VISIBILITY
bool
ios_base::fail() const
{
return __rdstate_ & (failbit | badbit);
}
inline _LIBCPP_INLINE_VISIBILITY
bool
ios_base::bad() const
{
return __rdstate_ & badbit;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base::iostate
ios_base::exceptions() const
{
return __exceptions_;
}
inline _LIBCPP_INLINE_VISIBILITY
void
ios_base::exceptions(iostate __except)
{
__exceptions_ = __except;
clear(__rdstate_);
}
template <class _CharT, class _Traits>
class basic_ios
: public ios_base
{
public:
// types:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
_LIBCPP_ALWAYS_INLINE // explicit
operator bool() const {return !fail();}
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
_LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
_LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
_LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();}
_LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
_LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();}
_LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
_LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);}
// 27.5.4.1 Constructor/destructor:
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
virtual ~basic_ios();
// 27.5.4.2 Members:
basic_ostream<char_type, traits_type>* tie() const;
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
basic_streambuf<char_type, traits_type>* rdbuf() const;
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
basic_ios& copyfmt(const basic_ios& __rhs);
char_type fill() const;
char_type fill(char_type __ch);
locale imbue(const locale& __loc);
char narrow(char_type __c, char __dfault) const;
char_type widen(char __c) const;
protected:
basic_ios() {// purposefully does no initialization
}
void init(basic_streambuf<char_type, traits_type>* __sb);
void move(basic_ios& __rhs);
#ifdef _LIBCPP_MOVE
void move(basic_ios&& __rhs) {move(__rhs);}
#endif
void swap(basic_ios& __rhs);
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
private:
basic_ostream<char_type, traits_type>* __tie_;
char_type __fill_;
};
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
{
init(__sb);
}
template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>::~basic_ios()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
{
ios_base::init(__sb);
__tie_ = 0;
__fill_ = widen(' ');
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::tie() const
{
return __tie_;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
{
basic_ostream<char_type, traits_type>* __r = __tie_;
__tie_ = __tiestr;
return __r;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_streambuf<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::rdbuf() const
{
return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_streambuf<_CharT, _Traits>*
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
{
basic_streambuf<char_type, traits_type>* __r = rdbuf();
ios_base::rdbuf(__sb);
return __r;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
locale
basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
{
locale __r = getloc();
ios_base::imbue(__loc);
if (rdbuf())
rdbuf()->pubimbue(__loc);
return __r;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
char
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
{
return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::widen(char __c) const
{
return use_facet<ctype<char_type> >(getloc()).widen(__c);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::fill() const
{
return __fill_;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::fill(char_type __ch)
{
char_type __r = __fill_;
__fill_ = __ch;
return __r;
}
template <class _CharT, class _Traits>
basic_ios<_CharT, _Traits>&
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
{
if (this != &__rhs)
{
__call_callbacks(erase_event);
ios_base::copyfmt(__rhs);
__tie_ = __rhs.__tie_;
__fill_ = __rhs.__fill_;
__call_callbacks(copyfmt_event);
exceptions(__rhs.exceptions());
}
return *this;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
{
ios_base::move(__rhs);
__tie_ = __rhs.__tie_;
__rhs.__tie_ = 0;
__fill_ = __rhs.__fill_;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs)
{
ios_base::swap(__rhs);
_STD::swap(__tie_, __rhs.__tie_);
_STD::swap(__fill_, __rhs.__fill_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
{
ios_base::set_rdbuf(__sb);
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
boolalpha(ios_base& __str)
{
__str.setf(ios_base::boolalpha);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
noboolalpha(ios_base& __str)
{
__str.unsetf(ios_base::boolalpha);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
showbase(ios_base& __str)
{
__str.setf(ios_base::showbase);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
noshowbase(ios_base& __str)
{
__str.unsetf(ios_base::showbase);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
showpoint(ios_base& __str)
{
__str.setf(ios_base::showpoint);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
noshowpoint(ios_base& __str)
{
__str.unsetf(ios_base::showpoint);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
showpos(ios_base& __str)
{
__str.setf(ios_base::showpos);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
noshowpos(ios_base& __str)
{
__str.unsetf(ios_base::showpos);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
skipws(ios_base& __str)
{
__str.setf(ios_base::skipws);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
noskipws(ios_base& __str)
{
__str.unsetf(ios_base::skipws);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
uppercase(ios_base& __str)
{
__str.setf(ios_base::uppercase);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
nouppercase(ios_base& __str)
{
__str.unsetf(ios_base::uppercase);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
unitbuf(ios_base& __str)
{
__str.setf(ios_base::unitbuf);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
nounitbuf(ios_base& __str)
{
__str.unsetf(ios_base::unitbuf);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
internal(ios_base& __str)
{
__str.setf(ios_base::internal, ios_base::adjustfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
left(ios_base& __str)
{
__str.setf(ios_base::left, ios_base::adjustfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
right(ios_base& __str)
{
__str.setf(ios_base::right, ios_base::adjustfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
dec(ios_base& __str)
{
__str.setf(ios_base::dec, ios_base::basefield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
hex(ios_base& __str)
{
__str.setf(ios_base::hex, ios_base::basefield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
oct(ios_base& __str)
{
__str.setf(ios_base::oct, ios_base::basefield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
fixed(ios_base& __str)
{
__str.setf(ios_base::fixed, ios_base::floatfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
scientific(ios_base& __str)
{
__str.setf(ios_base::scientific, ios_base::floatfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
hexfloat(ios_base& __str)
{
__str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
return __str;
}
inline _LIBCPP_INLINE_VISIBILITY
ios_base&
defaultfloat(ios_base& __str)
{
__str.unsetf(ios_base::floatfield);
return __str;
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOS

173
libcxx/include/iosfwd Normal file
View File

@ -0,0 +1,173 @@
// -*- C++ -*-
//===--------------------------- iosfwd -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_IOSFWD
#define _LIBCPP_IOSFWD
/*
iosfwd synopsis
namespace std
{
template<class charT> struct char_traits;
template<class T> class allocator;
template <class charT, class traits = char_traits<charT> > class basic_ios;
template <class charT, class traits = char_traits<charT> > class basic_streambuf;
template <class charT, class traits = char_traits<charT> > class basic_istream;
template <class charT, class traits = char_traits<charT> > class basic_ostream;
template <class charT, class traits = char_traits<charT> > class basic_iostream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringbuf;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_istringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_ostringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringstream;
template <class charT, class traits = char_traits<charT> > class basic_filebuf;
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
template <class charT, class traits = char_traits<charT> > class basic_fstream;
template <class charT, class traits = char_traits<charT> > class istreambuf_iterator;
template <class charT, class traits = char_traits<charT> > class ostreambuf_iterator;
typedef basic_ios<char> ios;
typedef basic_ios<wchar_t> wios;
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
template <class state> class fpos;
typedef fpos<char_traits<char>::state_type> streampos;
typedef fpos<char_traits<wchar_t>::state_type> wstreampos;
} // std
*/
#include <__config>
#include <_types.h> // for __darwin_mbstate_t
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template<class _CharT> struct char_traits;
template<class _Tp> class allocator;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_ios;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_streambuf;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_istream;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_ostream;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_iostream;
template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
class basic_stringbuf;
template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
class basic_istringstream;
template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
class basic_ostringstream;
template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
class basic_stringstream;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_filebuf;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_ifstream;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_ofstream;
template <class _CharT, class _Traits = char_traits<_CharT> > class basic_fstream;
template <class _CharT, class _Traits = char_traits<_CharT> > class istreambuf_iterator;
template <class _CharT, class _Traits = char_traits<_CharT> > class ostreambuf_iterator;
typedef basic_ios<char> ios;
typedef basic_ios<wchar_t> wios;
typedef basic_streambuf<char> streambuf;
typedef basic_istream<char> istream;
typedef basic_ostream<char> ostream;
typedef basic_iostream<char> iostream;
typedef basic_stringbuf<char> stringbuf;
typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
typedef basic_streambuf<wchar_t> wstreambuf;
typedef basic_istream<wchar_t> wistream;
typedef basic_ostream<wchar_t> wostream;
typedef basic_iostream<wchar_t> wiostream;
typedef basic_stringbuf<wchar_t> wstringbuf;
typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
typedef basic_fstream<wchar_t> wfstream;
template <class _State> class fpos;
typedef fpos<__darwin_mbstate_t> streampos;
typedef fpos<__darwin_mbstate_t> wstreampos;
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef fpos<__darwin_mbstate_t> u16streampos;
typedef fpos<__darwin_mbstate_t> u32streampos;
#endif
typedef long long streamoff; // for char_traits in <string>
template <class _CharT, // for <stdexcept>
class _Traits = char_traits<_CharT>,
class _Allocator = allocator<_CharT> > class basic_string;
typedef basic_string<char, char_traits<char>, allocator<char> > string;
typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOSFWD

58
libcxx/include/iostream Normal file
View File

@ -0,0 +1,58 @@
// -*- C++ -*-
//===--------------------------- iostream ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_IOSTREAM
#define _LIBCPP_IOSTREAM
/*
iostream synopsis
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
namespace std {
extern istream cin;
extern ostream cout;
extern ostream cerr;
extern ostream clog;
extern wistream wcin;
extern wostream wcout;
extern wostream wcerr;
extern wostream wclog;
} // std
*/
#include <__config>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
extern _LIBCPP_VISIBLE istream cin;
extern _LIBCPP_VISIBLE ostream cout;
extern _LIBCPP_VISIBLE ostream cerr;
extern _LIBCPP_VISIBLE ostream clog;
extern _LIBCPP_VISIBLE wistream wcin;
extern _LIBCPP_VISIBLE wostream wcout;
extern _LIBCPP_VISIBLE wostream wcerr;
extern _LIBCPP_VISIBLE wostream wclog;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_IOSTREAM

1733
libcxx/include/istream Normal file

File diff suppressed because it is too large Load Diff

1706
libcxx/include/iterator Normal file

File diff suppressed because it is too large Load Diff

613
libcxx/include/limits Normal file
View File

@ -0,0 +1,613 @@
// -*- C++ -*-
//===---------------------------- limits ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_LIMITS
#define _LIBCPP_LIMITS
/*
limits synopsis
namespace std
{
template<class T>
class numeric_limits
{
public:
static const bool is_specialized = false;
static T min() throw();
static T max() throw();
static T lowest() throw();
static const int digits = 0;
static const int digits10 = 0;
static const int max_digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
static T epsilon() throw();
static T round_error() throw();
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static T infinity() throw();
static T quiet_NaN() throw();
static T signaling_NaN() throw();
static T denorm_min() throw();
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
enum float_round_style
{
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum float_denorm_style
{
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
template<> class numeric_limits<cv bool>;
template<> class numeric_limits<cv char>;
template<> class numeric_limits<cv signed char>;
template<> class numeric_limits<cv unsigned char>;
template<> class numeric_limits<cv wchar_t>;
template<> class numeric_limits<cv char16_t>;
template<> class numeric_limits<cv char32_t>;
template<> class numeric_limits<cv short>;
template<> class numeric_limits<cv int>;
template<> class numeric_limits<cv long>;
template<> class numeric_limits<cv long long>;
template<> class numeric_limits<cv unsigned short>;
template<> class numeric_limits<cv unsigned int>;
template<> class numeric_limits<cv unsigned long>;
template<> class numeric_limits<cv unsigned long long>;
template<> class numeric_limits<cv float>;
template<> class numeric_limits<cv double>;
template<> class numeric_limits<cv long double>;
} // std
*/
#pragma GCC system_header
#include <__config>
#include <type_traits>
_LIBCPP_BEGIN_NAMESPACE_STD
enum float_round_style
{
round_indeterminate = -1,
round_toward_zero = 0,
round_to_nearest = 1,
round_toward_infinity = 2,
round_toward_neg_infinity = 3
};
enum float_denorm_style
{
denorm_indeterminate = -1,
denorm_absent = 0,
denorm_present = 1
};
template <class _Tp, bool = is_arithmetic<_Tp>::value>
class __libcpp_numeric_limits
{
protected:
typedef _Tp type;
static const bool is_specialized = false;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return type();}
static const int digits = 0;
static const int digits10 = 0;
static const int max_digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return type();}
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return type();}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return type();}
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
template <class _Tp, int digits, bool is_signed>
struct __libcpp_compute_min
{
static const _Tp value = _Tp(_Tp(1) << digits);
};
template <class _Tp, int digits>
struct __libcpp_compute_min<_Tp, digits, false>
{
static const _Tp value = _Tp(0);
};
template <class _Tp>
class __libcpp_numeric_limits<_Tp, true>
{
protected:
typedef _Tp type;
static const bool is_specialized = true;
static const bool is_signed = type(-1) < type(0);
static const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
static const int digits10 = digits * 3 / 10;
static const int max_digits10 = 0;
static const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
static const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __min;}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __max;}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return min();}
static const bool is_integer = true;
static const bool is_exact = true;
static const int radix = 2;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return type(0);}
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return type(0);}
static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = true;
#if __i386__ || __x86_64__
static const bool traps = true;
#else
static const bool traps = false;
#endif
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
template <>
class __libcpp_numeric_limits<bool, true>
{
protected:
typedef bool type;
static const bool is_specialized = true;
static const bool is_signed = false;
static const int digits = 1;
static const int digits10 = 0;
static const int max_digits10 = 0;
static const type __min = false;
static const type __max = true;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __min;}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __max;}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return min();}
static const bool is_integer = true;
static const bool is_exact = true;
static const int radix = 2;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return type(0);}
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return type(0);}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return type(0);}
static const bool is_iec559 = false;
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
template <>
class __libcpp_numeric_limits<float, true>
{
protected:
typedef float type;
static const bool is_specialized = true;
static const bool is_signed = true;
static const int digits = __FLT_MANT_DIG__;
static const int digits10 = __FLT_DIG__;
static const int max_digits10 = 2+(digits * 30103)/100000;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __FLT_MIN__;}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __FLT_MAX__;}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return -max();}
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = __FLT_RADIX__;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __FLT_EPSILON__;}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return 0.5F;}
static const int min_exponent = __FLT_MIN_EXP__;
static const int min_exponent10 = __FLT_MIN_10_EXP__;
static const int max_exponent = __FLT_MAX_EXP__;
static const int max_exponent10 = __FLT_MAX_10_EXP__;
static const bool has_infinity = true;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_present;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __builtin_huge_valf();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __builtin_nanf("");}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __builtin_nansf("");}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __FLT_DENORM_MIN__;}
static const bool is_iec559 = true;
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
};
template <>
class __libcpp_numeric_limits<double, true>
{
protected:
typedef double type;
static const bool is_specialized = true;
static const bool is_signed = true;
static const int digits = __DBL_MANT_DIG__;
static const int digits10 = __DBL_DIG__;
static const int max_digits10 = 2+(digits * 30103)/100000;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __DBL_MIN__;}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __DBL_MAX__;}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return -max();}
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = __FLT_RADIX__;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __DBL_EPSILON__;}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return 0.5;}
static const int min_exponent = __DBL_MIN_EXP__;
static const int min_exponent10 = __DBL_MIN_10_EXP__;
static const int max_exponent = __DBL_MAX_EXP__;
static const int max_exponent10 = __DBL_MAX_10_EXP__;
static const bool has_infinity = true;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_present;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __builtin_huge_val();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __builtin_nan("");}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __builtin_nans("");}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __DBL_DENORM_MIN__;}
static const bool is_iec559 = true;
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
};
template <>
class __libcpp_numeric_limits<long double, true>
{
protected:
typedef long double type;
static const bool is_specialized = true;
static const bool is_signed = true;
static const int digits = __LDBL_MANT_DIG__;
static const int digits10 = __LDBL_DIG__;
static const int max_digits10 = 2+(digits * 30103)/100000;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __LDBL_MIN__;}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __LDBL_MAX__;}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return -max();}
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = __FLT_RADIX__;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __LDBL_EPSILON__;}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return 0.5;}
static const int min_exponent = __LDBL_MIN_EXP__;
static const int min_exponent10 = __LDBL_MIN_10_EXP__;
static const int max_exponent = __LDBL_MAX_EXP__;
static const int max_exponent10 = __LDBL_MAX_10_EXP__;
static const bool has_infinity = true;
static const bool has_quiet_NaN = true;
static const bool has_signaling_NaN = true;
static const float_denorm_style has_denorm = denorm_present;
static const bool has_denorm_loss = false;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __builtin_huge_vall();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __builtin_nanl("");}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __builtin_nansl("");}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __LDBL_DENORM_MIN__;}
#if (defined(__ppc__) || defined(__ppc64__))
static const bool is_iec559 = false;
#else
static const bool is_iec559 = true;
#endif
static const bool is_bounded = true;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_to_nearest;
};
template <class _Tp>
class numeric_limits
: private __libcpp_numeric_limits<typename remove_cv<_Tp>::type>
{
typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base;
typedef typename __base::type type;
public:
static const bool is_specialized = __base::is_specialized;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __base::min();}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __base::max();}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return __base::lowest();}
static const int digits = __base::digits;
static const int digits10 = __base::digits10;
static const int max_digits10 = __base::max_digits10;
static const bool is_signed = __base::is_signed;
static const bool is_integer = __base::is_integer;
static const bool is_exact = __base::is_exact;
static const int radix = __base::radix;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __base::epsilon();}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return __base::round_error();}
static const int min_exponent = __base::min_exponent;
static const int min_exponent10 = __base::min_exponent10;
static const int max_exponent = __base::max_exponent;
static const int max_exponent10 = __base::max_exponent10;
static const bool has_infinity = __base::has_infinity;
static const bool has_quiet_NaN = __base::has_quiet_NaN;
static const bool has_signaling_NaN = __base::has_signaling_NaN;
static const float_denorm_style has_denorm = __base::has_denorm;
static const bool has_denorm_loss = __base::has_denorm_loss;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __base::infinity();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __base::quiet_NaN();}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __base::signaling_NaN();}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __base::denorm_min();}
static const bool is_iec559 = __base::is_iec559;
static const bool is_bounded = __base::is_bounded;
static const bool is_modulo = __base::is_modulo;
static const bool traps = __base::traps;
static const bool tinyness_before = __base::tinyness_before;
static const float_round_style round_style = __base::round_style;
};
template <class _Tp>
class numeric_limits<const _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static const bool is_specialized = __base::is_specialized;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __base::min();}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __base::max();}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return __base::lowest();}
static const int digits = __base::digits;
static const int digits10 = __base::digits10;
static const int max_digits10 = __base::max_digits10;
static const bool is_signed = __base::is_signed;
static const bool is_integer = __base::is_integer;
static const bool is_exact = __base::is_exact;
static const int radix = __base::radix;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __base::epsilon();}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return __base::round_error();}
static const int min_exponent = __base::min_exponent;
static const int min_exponent10 = __base::min_exponent10;
static const int max_exponent = __base::max_exponent;
static const int max_exponent10 = __base::max_exponent10;
static const bool has_infinity = __base::has_infinity;
static const bool has_quiet_NaN = __base::has_quiet_NaN;
static const bool has_signaling_NaN = __base::has_signaling_NaN;
static const float_denorm_style has_denorm = __base::has_denorm;
static const bool has_denorm_loss = __base::has_denorm_loss;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __base::infinity();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __base::quiet_NaN();}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __base::signaling_NaN();}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __base::denorm_min();}
static const bool is_iec559 = __base::is_iec559;
static const bool is_bounded = __base::is_bounded;
static const bool is_modulo = __base::is_modulo;
static const bool traps = __base::traps;
static const bool tinyness_before = __base::tinyness_before;
static const float_round_style round_style = __base::round_style;
};
template <class _Tp>
class numeric_limits<volatile _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static const bool is_specialized = __base::is_specialized;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __base::min();}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __base::max();}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return __base::lowest();}
static const int digits = __base::digits;
static const int digits10 = __base::digits10;
static const int max_digits10 = __base::max_digits10;
static const bool is_signed = __base::is_signed;
static const bool is_integer = __base::is_integer;
static const bool is_exact = __base::is_exact;
static const int radix = __base::radix;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __base::epsilon();}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return __base::round_error();}
static const int min_exponent = __base::min_exponent;
static const int min_exponent10 = __base::min_exponent10;
static const int max_exponent = __base::max_exponent;
static const int max_exponent10 = __base::max_exponent10;
static const bool has_infinity = __base::has_infinity;
static const bool has_quiet_NaN = __base::has_quiet_NaN;
static const bool has_signaling_NaN = __base::has_signaling_NaN;
static const float_denorm_style has_denorm = __base::has_denorm;
static const bool has_denorm_loss = __base::has_denorm_loss;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __base::infinity();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __base::quiet_NaN();}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __base::signaling_NaN();}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __base::denorm_min();}
static const bool is_iec559 = __base::is_iec559;
static const bool is_bounded = __base::is_bounded;
static const bool is_modulo = __base::is_modulo;
static const bool traps = __base::traps;
static const bool tinyness_before = __base::tinyness_before;
static const float_round_style round_style = __base::round_style;
};
template <class _Tp>
class numeric_limits<const volatile _Tp>
: private numeric_limits<_Tp>
{
typedef numeric_limits<_Tp> __base;
typedef _Tp type;
public:
static const bool is_specialized = __base::is_specialized;
_LIBCPP_INLINE_VISIBILITY static type min() throw() {return __base::min();}
_LIBCPP_INLINE_VISIBILITY static type max() throw() {return __base::max();}
_LIBCPP_INLINE_VISIBILITY static type lowest() throw() {return __base::lowest();}
static const int digits = __base::digits;
static const int digits10 = __base::digits10;
static const int max_digits10 = __base::max_digits10;
static const bool is_signed = __base::is_signed;
static const bool is_integer = __base::is_integer;
static const bool is_exact = __base::is_exact;
static const int radix = __base::radix;
_LIBCPP_INLINE_VISIBILITY static type epsilon() throw() {return __base::epsilon();}
_LIBCPP_INLINE_VISIBILITY static type round_error() throw() {return __base::round_error();}
static const int min_exponent = __base::min_exponent;
static const int min_exponent10 = __base::min_exponent10;
static const int max_exponent = __base::max_exponent;
static const int max_exponent10 = __base::max_exponent10;
static const bool has_infinity = __base::has_infinity;
static const bool has_quiet_NaN = __base::has_quiet_NaN;
static const bool has_signaling_NaN = __base::has_signaling_NaN;
static const float_denorm_style has_denorm = __base::has_denorm;
static const bool has_denorm_loss = __base::has_denorm_loss;
_LIBCPP_INLINE_VISIBILITY static type infinity() throw() {return __base::infinity();}
_LIBCPP_INLINE_VISIBILITY static type quiet_NaN() throw() {return __base::quiet_NaN();}
_LIBCPP_INLINE_VISIBILITY static type signaling_NaN() throw() {return __base::signaling_NaN();}
_LIBCPP_INLINE_VISIBILITY static type denorm_min() throw() {return __base::denorm_min();}
static const bool is_iec559 = __base::is_iec559;
static const bool is_bounded = __base::is_bounded;
static const bool is_modulo = __base::is_modulo;
static const bool traps = __base::traps;
static const bool tinyness_before = __base::tinyness_before;
static const float_round_style round_style = __base::round_style;
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_LIMITS

1531
libcxx/include/list Normal file

File diff suppressed because it is too large Load Diff

3369
libcxx/include/locale Normal file

File diff suppressed because it is too large Load Diff

1663
libcxx/include/map Normal file

File diff suppressed because it is too large Load Diff

3824
libcxx/include/memory Normal file

File diff suppressed because it is too large Load Diff

516
libcxx/include/mutex Normal file
View File

@ -0,0 +1,516 @@
// -*- C++ -*-
//===--------------------------- mutex ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_MUTEX
#define _LIBCPP_MUTEX
/*
mutex synopsis
namespace std
{
class mutex
{
public:
mutex();
~mutex();
mutex(const mutex&) = delete;
mutex& operator=(const mutex&) = delete;
void lock();
bool try_lock();
void unlock();
typedef pthread_mutex_t* native_handle_type;
native_handle_type native_handle();
};
class recursive_mutex
{
public:
recursive_mutex();
~recursive_mutex();
recursive_mutex(const recursive_mutex&) = delete;
recursive_mutex& operator=(const recursive_mutex&) = delete;
void lock();
bool try_lock();
void unlock();
typedef pthread_mutex_t* native_handle_type;
native_handle_type native_handle();
};
class timed_mutex
{
public:
timed_mutex();
~timed_mutex();
timed_mutex(const timed_mutex&) = delete;
timed_mutex& operator=(const timed_mutex&) = delete;
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
};
class recursive_timed_mutex
{
public:
recursive_timed_mutex();
~recursive_timed_mutex();
recursive_timed_mutex(const recursive_timed_mutex&) = delete;
recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
};
struct defer_lock_t {};
struct try_to_lock_t {};
struct adopt_lock_t {};
constexpr defer_lock_t defer_lock{};
constexpr try_to_lock_t try_to_lock{};
constexpr adopt_lock_t adopt_lock{};
template <class Mutex>
class lock_guard
{
public:
typedef Mutex mutex_type;
explicit lock_guard(mutex_type& m);
lock_guard(mutex_type& m, adopt_lock_t);
~lock_guard();
lock_guard(lock_guard const&) = delete;
lock_guard& operator=(lock_guard const&) = delete;
};
template <class Mutex>
class unique_lock
{
public:
typedef Mutex mutex_type;
unique_lock();
explicit unique_lock(mutex_type& m);
unique_lock(mutex_type& m, defer_lock_t);
unique_lock(mutex_type& m, try_to_lock_t);
unique_lock(mutex_type& m, adopt_lock_t);
template <class Clock, class Duration>
unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
template <class Rep, class Period>
unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
~unique_lock();
unique_lock(unique_lock const&) = delete;
unique_lock& operator=(unique_lock const&) = delete;
unique_lock(unique_lock&& u);
unique_lock& operator=(unique_lock&& u);
void lock();
bool try_lock();
template <class Rep, class Period>
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
template <class Clock, class Duration>
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
void unlock();
void swap(unique_lock& u);
mutex_type* release();
bool owns_lock() const;
explicit operator bool () const;
mutex_type* mutex() const;
};
template <class Mutex>
void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y);
template <class L1, class L2, class... L3>
int try_lock(L1&, L2&, L3&...);
template <class L1, class L2, class... L3>
void lock(L1&, L2&, L3&...);
struct once_flag
{
constexpr once_flag();
once_flag(const once_flag&) = delete;
once_flag& operator=(const once_flag&) = delete;
};
template<class Callable, class ...Args>
void call_once(once_flag& flag, Callable&& func, Args&&... args);
} // std
*/
#include <__config>
#include <__mutex_base>
#include <functional>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
class recursive_mutex
{
pthread_mutex_t __m_;
public:
recursive_mutex();
~recursive_mutex();
private:
recursive_mutex(const recursive_mutex&); // = delete;
recursive_mutex& operator=(const recursive_mutex&); // = delete;
public:
void lock();
bool try_lock();
void unlock();
typedef pthread_mutex_t* native_handle_type;
native_handle_type native_handle() {return &__m_;}
};
class timed_mutex
{
mutex __m_;
condition_variable __cv_;
bool __locked_;
public:
timed_mutex();
~timed_mutex();
private:
timed_mutex(const timed_mutex&); // = delete;
timed_mutex& operator=(const timed_mutex&); // = delete;
public:
void lock();
bool try_lock();
template <class _Rep, class _Period>
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
{return try_lock_until(chrono::monotonic_clock::now() + __d);}
template <class _Clock, class _Duration>
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
void unlock();
};
template <class _Clock, class _Duration>
bool
timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
{
using namespace chrono;
unique_lock<mutex> __lk(__m_);
bool no_timeout = _Clock::now() < __t;
while (no_timeout && __locked_)
no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
if (!__locked_)
{
__locked_ = true;
return true;
}
return false;
}
class recursive_timed_mutex
{
mutex __m_;
condition_variable __cv_;
size_t __count_;
pthread_t __id_;
public:
recursive_timed_mutex();
~recursive_timed_mutex();
private:
recursive_timed_mutex(const recursive_timed_mutex&); // = delete;
recursive_timed_mutex& operator=(const recursive_timed_mutex&); // = delete;
public:
void lock();
bool try_lock();
template <class _Rep, class _Period>
bool try_lock_for(const chrono::duration<_Rep, _Period>& __d)
{return try_lock_until(chrono::monotonic_clock::now() + __d);}
template <class _Clock, class _Duration>
bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
void unlock();
};
template <class _Clock, class _Duration>
bool
recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t)
{
using namespace chrono;
pthread_t __id = pthread_self();
unique_lock<mutex> lk(__m_);
if (pthread_equal(__id, __id_))
{
if (__count_ == numeric_limits<size_t>::max())
return false;
++__count_;
return true;
}
bool no_timeout = _Clock::now() < __t;
while (no_timeout && __count_ != 0)
no_timeout = __cv_.wait_until(lk, __t) == cv_status::no_timeout;
if (__count_ == 0)
{
__count_ = 1;
__id_ = __id;
return true;
}
return false;
}
template <class _L0, class _L1>
int
try_lock(_L0& __l0, _L1& __l1)
{
unique_lock<_L0> __u0(__l0, try_to_lock);
if (__u0.owns_lock())
{
if (__l1.try_lock())
{
__u0.release();
return -1;
}
else
return 1;
}
return 0;
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _L0, class _L1, class _L2, class... _L3>
int
try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
{
int __r = 0;
unique_lock<_L0> __u0(__l0, try_to_lock);
if (__u0.owns_lock())
{
__r = try_lock(__l1, __l2, __l3...);
if (__r == -1)
__u0.release();
else
++__r;
}
return __r;
}
#endif
template <class _L0, class _L1>
void
lock(_L0& __l0, _L1& __l1)
{
while (true)
{
{
unique_lock<_L0> __u0(__l0);
if (__l1.try_lock())
{
__u0.release();
break;
}
}
sched_yield();
{
unique_lock<_L1> __u1(__l1);
if (__l0.try_lock())
{
__u1.release();
break;
}
}
sched_yield();
}
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _L0, class _L1, class ..._L2>
void
__lock_first(int __i, _L0& __l0, _L1& __l1, _L2& ...__l2)
{
while (true)
{
switch (__i)
{
case 0:
{
unique_lock<_L0> __u0(__l0);
__i = try_lock(__l1, __l2...);
if (__i == -1)
{
__u0.release();
return;
}
}
++__i;
sched_yield();
break;
case 1:
{
unique_lock<_L1> __u1(__l1);
__i = try_lock(__l2..., __l0);
if (__i == -1)
{
__u1.release();
return;
}
}
if (__i == sizeof...(_L2))
__i = 0;
else
__i += 2;
sched_yield();
break;
default:
__lock_first(__i - 2, __l2..., __l0, __l1);
return;
}
}
}
template <class _L0, class _L1, class ..._L2>
inline
void
lock(_L0& __l0, _L1& __l1, _L2& ...__l2)
{
__lock_first(0, __l0, __l1, __l2...);
}
#endif
struct once_flag;
#ifndef _LIBCPP_HAS_NO_VARIADICS
template<class _Callable, class... _Args>
void call_once(once_flag&, _Callable&&, _Args&&...);
#else
template<class _Callable>
void call_once(once_flag&, _Callable);
#endif
struct once_flag
{
// constexpr
once_flag() {}
private:
once_flag(const once_flag&); // = delete;
once_flag& operator=(const once_flag&); // = delete;
unsigned long __state_;
#ifndef _LIBCPP_HAS_NO_VARIADICS
template<class _Callable, class... _Args>
friend
void call_once(once_flag&, _Callable&&, _Args&&...);
#else
template<class _Callable>
friend
void call_once(once_flag&, _Callable);
#endif
};
template <class _F>
class __call_once_param
{
_F __f_;
public:
#ifdef _LIBCPP_MOVE
explicit __call_once_param(_F&& __f) : __f_(_STD::move(__f)) {}
#else
explicit __call_once_param(const _F& __f) : __f_(__f) {}
#endif
void operator()()
{
__f_();
}
};
template <class _F>
void
__call_once_proxy(void* __vp)
{
__call_once_param<_F>* __p = static_cast<__call_once_param<_F>*>(__vp);
(*__p)();
}
void __call_once(volatile unsigned long&, void*, void(*)(void*));
#ifndef _LIBCPP_HAS_NO_VARIADICS
template<class _Callable, class... _Args>
inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
{
if (__builtin_expect(__flag.__state_ , ~0ul) != ~0ul)
{
typedef decltype(std::bind(std::forward<_Callable>(__func),
std::forward<_Args>(__args)...)) _G;
__call_once_param<_G> __p(std::bind(std::forward<_Callable>(__func),
std::forward<_Args>(__args)...));
__call_once(__flag.__state_, &__p, &__call_once_proxy<_G>);
}
}
#else
template<class _Callable>
inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable __func)
{
if (__flag.__state_ != ~0ul)
{
__call_once_param<_Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
}
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_MUTEX

106
libcxx/include/new Normal file
View File

@ -0,0 +1,106 @@
// -*- C++ -*-
//===----------------------------- new ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_NEW
#define _LIBCPP_NEW
/*
new synopsis
namespace std
{
class bad_alloc
: public exception
{
public:
bad_alloc() throw();
bad_alloc(const bad_alloc&) throw();
bad_alloc& operator=(const bad_alloc&) throw();
virtual ~bad_alloc() throw();
virtual const char* what() const throw();
};
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
new_handler set_new_handler(new_handler new_p) throw();
} // std
void* operator new(std::size_t size) throw(std::bad_alloc); // replaceable
void* operator new(std::size_t size, const std::nothrow_t&) throw(); // replaceable
void operator delete(void* ptr) throw(); // replaceable
void operator delete(void* ptr, const std::nothrow_t&) throw(); // replaceable
void* operator new[](std::size_t size) throw(std::bad_alloc); // replaceable
void* operator new[](std::size_t size, const std::nothrow_t&) throw(); // replaceable
void operator delete[](void* ptr) throw(); // replaceable
void operator delete[](void* ptr, const std::nothrow_t&) throw(); // replaceable
void* operator new (std::size_t size, void* ptr) throw();
void* operator new[](std::size_t size, void* ptr) throw();
void operator delete (void* ptr, void*) throw();
void operator delete[](void* ptr, void*) throw();
*/
#include <__config>
#include <exception>
#include <cstddef>
#pragma GCC system_header
namespace std // purposefully not using versioning namespace
{
class _LIBCPP_EXCEPTION_ABI bad_alloc
: public exception
{
public:
_LIBCPP_INLINE_VISIBILITY bad_alloc() throw() {}
virtual ~bad_alloc() throw();
virtual const char* what() const throw();
};
class _LIBCPP_EXCEPTION_ABI bad_array_new_length
: public bad_alloc
{
public:
_LIBCPP_INLINE_VISIBILITY bad_array_new_length() throw() {}
virtual ~bad_array_new_length() throw();
virtual const char* what() const throw();
};
void __throw_bad_alloc();
struct nothrow_t {};
extern _LIBCPP_VISIBLE const nothrow_t nothrow;
typedef void (*new_handler)();
_LIBCPP_VISIBLE new_handler set_new_handler(new_handler) throw();
} // std
_LIBCPP_VISIBLE void* operator new(std::size_t) throw(std::bad_alloc);
_LIBCPP_VISIBLE void* operator new(std::size_t, const std::nothrow_t&) throw();
_LIBCPP_VISIBLE void operator delete(void*) throw();
_LIBCPP_VISIBLE void operator delete(void*, const std::nothrow_t&) throw();
_LIBCPP_VISIBLE void* operator new[](std::size_t) throw(std::bad_alloc);
_LIBCPP_VISIBLE void* operator new[](std::size_t, const std::nothrow_t&) throw();
_LIBCPP_VISIBLE void operator delete[](void*) throw();
_LIBCPP_VISIBLE void operator delete[](void*, const std::nothrow_t&) throw();
_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) throw() {return __p;}
_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) throw() {return __p;}
_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) throw() {}
_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) throw() {}
#endif // _LIBCPP_NEW

183
libcxx/include/numeric Normal file
View File

@ -0,0 +1,183 @@
// -*- C++ -*-
//===---------------------------- numeric ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_NUMERIC
#define _LIBCPP_NUMERIC
/*
numeric synopsis
namespace std
{
template <class InputIterator, class T>
T
accumulate(InputIterator first, InputIterator last, T init);
template <class InputIterator, class T, class BinaryOperation>
T
accumulate(InputIterator first, InputIterator last, T init, BinaryOperation binary_op);
template <class InputIterator1, class InputIterator2, class T>
T
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init);
template <class InputIterator1, class InputIterator2, class T, class BinaryOperation1, class BinaryOperation2>
T
inner_product(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
template <class InputIterator, class OutputIterator>
OutputIterator
partial_sum(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
OutputIterator
partial_sum(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
template <class InputIterator, class OutputIterator>
OutputIterator
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result);
template <class InputIterator, class OutputIterator, class BinaryOperation>
OutputIterator
adjacent_difference(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op);
} // std
*/
#include <__config>
#include <iterator>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _InputIterator, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
for (; __first != __last; ++__first)
__init = __init + *__first;
return __init;
}
template <class _InputIterator, class _Tp, class _BinaryOperation>
inline _LIBCPP_INLINE_VISIBILITY
_Tp
accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op)
{
for (; __first != __last; ++__first)
__init = __binary_op(__init, *__first);
return __init;
}
template <class _InputIterator1, class _InputIterator2, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
{
for (; __first1 != __last1; ++__first1, ++__first2)
__init = __init + *__first1 * *__first2;
return __init;
}
template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
inline _LIBCPP_INLINE_VISIBILITY
_Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2,
_Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2)
{
for (; __first1 != __last1; ++__first1, ++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init;
}
template <class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
if (__first != __last)
{
typename iterator_traits<_InputIterator>::value_type __t(*__first);
*__result = __t;
for (++__first, ++__result; __first != __last; ++__first, ++__result)
{
__t = __t + *__first;
*__result = __t;
}
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
{
if (__first != __last)
{
typename iterator_traits<_InputIterator>::value_type __t(*__first);
*__result = __t;
for (++__first, ++__result; __first != __last; ++__first, ++__result)
{
__t = __binary_op(__t, *__first);
*__result = __t;
}
}
return __result;
}
template <class _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
{
if (__first != __last)
{
typename iterator_traits<_InputIterator>::value_type __t1(*__first);
*__result = __t1;
for (++__first, ++__result; __first != __last; ++__first, ++__result)
{
typename iterator_traits<_InputIterator>::value_type __t2(*__first);
*__result = __t2 - __t1;
__t1 = __t2;
}
}
return __result;
}
template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
inline _LIBCPP_INLINE_VISIBILITY
_OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result,
_BinaryOperation __binary_op)
{
if (__first != __last)
{
typename iterator_traits<_InputIterator>::value_type __t1(*__first);
*__result = __t1;
for (++__first, ++__result; __first != __last; ++__first, ++__result)
{
typename iterator_traits<_InputIterator>::value_type __t2(*__first);
*__result = __binary_op(__t2, __t1);
__t1 = __t2;
}
}
return __result;
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_NUMERIC

1291
libcxx/include/ostream Normal file

File diff suppressed because it is too large Load Diff

629
libcxx/include/queue Normal file
View File

@ -0,0 +1,629 @@
// -*- C++ -*-
//===--------------------------- queue ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_QUEUE
#define _LIBCPP_QUEUE
/*
queue synopsis
namespace std
{
template <class T, class Container = deque<T>>
class queue
{
public:
typedef Container container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
public:
queue();
explicit queue(const container_type& c);
explicit queue(container_type&& c);
queue(queue&& q);
template <class Alloc>
explicit queue(const Alloc& a);
template <class Alloc>
queue(const container_type& c, const Alloc& a);
template <class Alloc>
queue(container_type&& c, const Alloc& a);
template <class Alloc>
queue(queue&& q, const Alloc& a);
queue& operator=(queue&& q);
bool empty() const;
size_type size() const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
void push(const value_type& v);
void push(value_type&& v);
template <class... Args> void emplace(Args&&... args);
void pop();
void swap(queue& q);
};
template <class T, class Container>
bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
template <class T, class Container>
void swap(queue<T, Container>& x, queue<T, Container>& y);
template <class T, class Container = vector<T>,
class Compare = less<typename Container::value_type>>
class priority_queue
{
public:
typedef Container container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
Compare comp;
public:
explicit priority_queue(const Compare& comp = Compare());
priority_queue(const Compare& comp, const container_type& c);
explicit priority_queue(const Compare& comp, container_type&& c);
template <class InputIterator>
priority_queue(InputIterator first, InputIterator last,
const Compare& comp = Compare());
template <class InputIterator>
priority_queue(InputIterator first, InputIterator last,
const Compare& comp, const container_type& c);
template <class InputIterator>
priority_queue(InputIterator first, InputIterator last,
const Compare& comp, container_type&& c);
priority_queue(priority_queue&& q);
priority_queue& operator=(priority_queue&& q);
template <class Alloc>
explicit priority_queue(const Alloc& a);
template <class Alloc>
priority_queue(const Compare& comp, const Alloc& a);
template <class Alloc>
priority_queue(const Compare& comp, const container_type& c,
const Alloc& a);
template <class Alloc>
priority_queue(const Compare& comp, container_type&& c,
const Alloc& a);
template <class Alloc>
priority_queue(priority_queue&& q, const Alloc& a);
bool empty() const;
size_type size() const;
const_reference top() const;
void push(const value_type& v);
void push(value_type&& v);
template <class... Args> void emplace(Args&&... args);
void pop();
void swap(priority_queue& q);
};
template <class T, class Container, class Compare>
void swap(priority_queue<T, Container, Compare>& x,
priority_queue<T, Container, Compare>& y);
} // std
*/
#include <__config>
#include <deque>
#include <vector>
#include <functional>
#include <algorithm>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Container> class queue;
template <class _Tp, class _Container>
bool
operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
template <class _Tp, class _Container>
bool
operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);
template <class _Tp, class _Container = deque<_Tp> >
class queue
{
public:
typedef _Container container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
public:
queue() : c() {}
explicit queue(const container_type& __c) : c(__c) {}
#ifdef _LIBCPP_MOVE
explicit queue(container_type&& __c) : c(_STD::move(__c)) {}
queue(queue&& __q) : c(_STD::move(__q.c)) {}
#endif
template <class _Alloc>
explicit queue(const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__a) {}
template <class _Alloc>
queue(const queue& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__q.c, __a) {}
template <class _Alloc>
queue(const container_type& __c, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__c, __a) {}
#ifdef _LIBCPP_MOVE
template <class _Alloc>
queue(container_type&& __c, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(_STD::move(__c), __a) {}
template <class _Alloc>
queue(queue&& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(_STD::move(__q.c), __a) {}
queue& operator=(queue&& __q)
{
c = _STD::move(__q.c);
return *this;
}
#endif
bool empty() const {return c.empty();}
size_type size() const {return c.size();}
reference front() {return c.front();}
const_reference front() const {return c.front();}
reference back() {return c.back();}
const_reference back() const {return c.back();}
void push(const value_type& __v) {c.push_back(__v);}
#ifdef _LIBCPP_MOVE
void push(value_type&& __v) {c.push_back(_STD::move(__v));}
template <class... _Args>
void emplace(_Args&&... __args)
{c.emplace_back(_STD::forward<_Args>(__args)...);}
#endif
void pop() {c.pop_front();}
void swap(queue& __q)
{
using _STD::swap;
swap(c, __q.c);
}
template <class _T1, class _C1>
friend
bool
operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
template <class _T1, class _C1>
friend
bool
operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
};
template <class _Tp, class _Container>
inline
bool
operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return __x.c == __y.c;
}
template <class _Tp, class _Container>
inline
bool
operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return __x.c < __y.c;
}
template <class _Tp, class _Container>
inline
bool
operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return !(__x == __y);
}
template <class _Tp, class _Container>
inline
bool
operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return __y < __x;
}
template <class _Tp, class _Container>
inline
bool
operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return !(__x < __y);
}
template <class _Tp, class _Container>
inline
bool
operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)
{
return !(__y < __x);
}
template <class _Tp, class _Container>
inline
void
swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
{
__x.swap(__y);
}
template <class _Tp, class _Container, class _Alloc>
struct uses_allocator<queue<_Tp, _Container>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};
template <class _Tp, class _Container = vector<_Tp>,
class _Compare = less<typename _Container::value_type> >
class priority_queue
{
public:
typedef _Container container_type;
typedef _Compare value_compare;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
value_compare comp;
public:
explicit priority_queue(const value_compare& __comp = value_compare())
: c(), comp(__comp) {}
priority_queue(const value_compare& __comp, const container_type& __c);
#ifdef _LIBCPP_MOVE
explicit priority_queue(const value_compare& __comp, container_type&& __c);
#endif
template <class _InputIter>
priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp = value_compare());
template <class _InputIter>
priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp, const container_type& __c);
#ifdef _LIBCPP_MOVE
template <class _InputIter>
priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp, container_type&& __c);
priority_queue(priority_queue&& __q);
priority_queue& operator=(priority_queue&& __q);
#endif
template <class _Alloc>
explicit priority_queue(const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
template <class _Alloc>
priority_queue(const value_compare& __comp, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
template <class _Alloc>
priority_queue(const value_compare& __comp, const container_type& __c,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
template <class _Alloc>
priority_queue(const priority_queue& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
#ifdef _LIBCPP_MOVE
template <class _Alloc>
priority_queue(const value_compare& __comp, container_type&& __c,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
template <class _Alloc>
priority_queue(priority_queue&& __q, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0);
#endif
bool empty() const {return c.empty();}
size_type size() const {return c.size();}
const_reference top() const {return c.front();}
void push(const value_type& __v);
#ifdef _LIBCPP_MOVE
void push(value_type&& __v);
template <class... _Args> void emplace(_Args&&... __args);
#endif
void pop();
void swap(priority_queue& __q);
};
template <class _Tp, class _Container, class _Compare>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
const container_type& __c)
: c(__c),
comp(__comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Container, class _Compare>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
container_type&& __c)
: c(_STD::move(__c)),
comp(__comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
#endif
template <class _Tp, class _Container, class _Compare>
template <class _InputIter>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp)
: c(__f, __l),
comp(__comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
template <class _Tp, class _Container, class _Compare>
template <class _InputIter>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp,
const container_type& __c)
: c(__c),
comp(__comp)
{
c.insert(c.end(), __f, __l);
_STD::make_heap(c.begin(), c.end(), comp);
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Container, class _Compare>
template <class _InputIter>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,
const value_compare& __comp,
container_type&& __c)
: c(_STD::move(__c)),
comp(__comp)
{
c.insert(c.end(), __f, __l);
_STD::make_heap(c.begin(), c.end(), comp);
}
template <class _Tp, class _Container, class _Compare>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q)
: c(_STD::move(__q.c)),
comp(_STD::move(__q.comp))
{
}
template <class _Tp, class _Container, class _Compare>
priority_queue<_Tp, _Container, _Compare>&
priority_queue<_Tp, _Container, _Compare>::operator=(priority_queue&& __q)
{
c = _STD::move(__q.c);
comp = _STD::move(__q.comp);
return *this;
}
#endif
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(__a)
{
}
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(__a),
comp(__comp)
{
}
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
const container_type& __c,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(__c, __a),
comp(__comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(__q.c, __a),
comp(__q.comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,
container_type&& __c,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(_STD::move(__c), __a),
comp(__comp)
{
_STD::make_heap(c.begin(), c.end(), comp);
}
template <class _Tp, class _Container, class _Compare>
template <class _Alloc>
inline
priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,
const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type*)
: c(_STD::move(__q.c), __a),
comp(_STD::move(__q.comp))
{
_STD::make_heap(c.begin(), c.end(), comp);
}
#endif
template <class _Tp, class _Container, class _Compare>
inline
void
priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)
{
c.push_back(__v);
_STD::push_heap(c.begin(), c.end(), comp);
}
#ifdef _LIBCPP_MOVE
template <class _Tp, class _Container, class _Compare>
inline
void
priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)
{
c.push_back(_STD::move(__v));
_STD::push_heap(c.begin(), c.end(), comp);
}
template <class _Tp, class _Container, class _Compare>
template <class... _Args>
inline
void
priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)
{
c.emplace_back(_STD::forward<_Args>(__args)...);
_STD::push_heap(c.begin(), c.end(), comp);
}
#endif
template <class _Tp, class _Container, class _Compare>
inline
void
priority_queue<_Tp, _Container, _Compare>::pop()
{
_STD::pop_heap(c.begin(), c.end(), comp);
c.pop_back();
}
template <class _Tp, class _Container, class _Compare>
inline
void
priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
{
using _STD::swap;
swap(c, __q.c);
swap(comp, __q.comp);
}
template <class _Tp, class _Container, class _Compare>
inline
void
swap(priority_queue<_Tp, _Container, _Compare>& __x,
priority_queue<_Tp, _Container, _Compare>& __y)
{
__x.swap(__y);
}
template <class _Tp, class _Container, class _Compare, class _Alloc>
struct uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_QUEUE

2851
libcxx/include/random Normal file

File diff suppressed because it is too large Load Diff

424
libcxx/include/ratio Normal file
View File

@ -0,0 +1,424 @@
// -*- C++ -*-
//===---------------------------- ratio -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_RATIO
#define _LIBCPP_RATIO
/*
ratio synopsis
namespace std
{
template <intmax_t N, intmax_t D = 1>
class ratio
{
public:
static const intmax_t num;
static const intmax_t den;
};
// ratio arithmetic
template <class R1, class R2> struct ratio_add;
template <class R1, class R2> struct ratio_subtract;
template <class R1, class R2> struct ratio_multiply;
template <class R1, class R2> struct ratio_divide;
// ratio comparison
template <class R1, class R2> struct ratio_equal;
template <class R1, class R2> struct ratio_not_equal;
template <class R1, class R2> struct ratio_less;
template <class R1, class R2> struct ratio_less_equal;
template <class R1, class R2> struct ratio_greater;
template <class R1, class R2> struct ratio_greater_equal;
// convenience SI typedefs
typedef ratio<1, 1000000000000000000000000> yocto; // not supported
typedef ratio<1, 1000000000000000000000> zepto; // not supported
typedef ratio<1, 1000000000000000000> atto;
typedef ratio<1, 1000000000000000> femto;
typedef ratio<1, 1000000000000> pico;
typedef ratio<1, 1000000000> nano;
typedef ratio<1, 1000000> micro;
typedef ratio<1, 1000> milli;
typedef ratio<1, 100> centi;
typedef ratio<1, 10> deci;
typedef ratio< 10, 1> deca;
typedef ratio< 100, 1> hecto;
typedef ratio< 1000, 1> kilo;
typedef ratio< 1000000, 1> mega;
typedef ratio< 1000000000, 1> giga;
typedef ratio< 1000000000000, 1> tera;
typedef ratio< 1000000000000000, 1> peta;
typedef ratio< 1000000000000000000, 1> exa;
typedef ratio< 1000000000000000000000, 1> zetta; // not supported
typedef ratio<1000000000000000000000000, 1> yotta; // not supported
}
*/
#include <__config>
#include <cstdint>
#include <climits>
#include <type_traits>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
// __static_gcd
template <intmax_t _Xp, intmax_t _Yp>
struct __static_gcd
{
static const intmax_t value = __static_gcd<_Yp, _Xp % _Yp>::value;
};
template <intmax_t _Xp>
struct __static_gcd<_Xp, 0>
{
static const intmax_t value = _Xp;
};
// __static_lcm
template <intmax_t _Xp, intmax_t _Yp>
struct __static_lcm
{
static const intmax_t value = _Xp / __static_gcd<_Xp, _Yp>::value * _Yp;
};
template <intmax_t _Xp>
struct __static_abs
{
static const intmax_t value = _Xp < 0 ? -_Xp : _Xp;
};
template <intmax_t _Xp>
struct __static_sign
{
static const intmax_t value = _Xp == 0 ? 0 : (_Xp < 0 ? -1 : 1);
};
template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
class __ll_add;
template <intmax_t _Xp, intmax_t _Yp>
class __ll_add<_Xp, _Yp, 1>
{
static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
static const intmax_t max = -min;
static_assert(_Xp <= max - _Yp, "overflow in __ll_add");
public:
static const intmax_t value = _Xp + _Yp;
};
template <intmax_t _Xp, intmax_t _Yp>
class __ll_add<_Xp, _Yp, 0>
{
public:
static const intmax_t value = _Xp;
};
template <intmax_t _Xp, intmax_t _Yp>
class __ll_add<_Xp, _Yp, -1>
{
static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
static const intmax_t max = -min;
static_assert(min - _Yp <= _Xp, "overflow in __ll_add");
public:
static const intmax_t value = _Xp + _Yp;
};
template <intmax_t _Xp, intmax_t _Yp, intmax_t = __static_sign<_Yp>::value>
class __ll_sub;
template <intmax_t _Xp, intmax_t _Yp>
class __ll_sub<_Xp, _Yp, 1>
{
static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
static const intmax_t max = -min;
static_assert(min + _Yp <= _Xp, "overflow in __ll_sub");
public:
static const intmax_t value = _Xp - _Yp;
};
template <intmax_t _Xp, intmax_t _Yp>
class __ll_sub<_Xp, _Yp, 0>
{
public:
static const intmax_t value = _Xp;
};
template <intmax_t _Xp, intmax_t _Yp>
class __ll_sub<_Xp, _Yp, -1>
{
static const intmax_t min = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1;
static const intmax_t max = -min;
static_assert(_Xp <= max + _Yp, "overflow in __ll_sub");
public:
static const intmax_t value = _Xp - _Yp;
};
template <intmax_t _Xp, intmax_t _Yp>
class __ll_mul
{
static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
static const intmax_t min = nan + 1;
static const intmax_t max = -min;
static const intmax_t __a_x = __static_abs<_Xp>::value;
static const intmax_t __a_y = __static_abs<_Yp>::value;
static_assert(_Xp != nan && _Yp != nan && __a_x <= max / __a_y, "overflow in __ll_mul");
public:
static const intmax_t value = _Xp * _Yp;
};
template <intmax_t _Yp>
class __ll_mul<0, _Yp>
{
public:
static const intmax_t value = 0;
};
template <intmax_t _Xp>
class __ll_mul<_Xp, 0>
{
public:
static const intmax_t value = 0;
};
template <>
class __ll_mul<0, 0>
{
public:
static const intmax_t value = 0;
};
// Not actually used but left here in case needed in future maintenance
template <intmax_t _Xp, intmax_t _Yp>
class __ll_div
{
static const intmax_t nan = (1LL << (sizeof(intmax_t) * CHAR_BIT - 1));
static const intmax_t min = nan + 1;
static const intmax_t max = -min;
static_assert(_Xp != nan && _Yp != nan && _Yp != 0, "overflow in __ll_div");
public:
static const intmax_t value = _Xp / _Yp;
};
template <intmax_t _Num, intmax_t _Den = 1>
class ratio
{
static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range");
static_assert(_Den != 0, "ratio divide by 0");
static_assert(__static_abs<_Den>::value > 0, "ratio denominator is out of range");
static const intmax_t __na = __static_abs<_Num>::value;
static const intmax_t __da = __static_abs<_Den>::value;
static const intmax_t __s = __static_sign<_Num>::value * __static_sign<_Den>::value;
static const intmax_t __gcd = __static_gcd<__na, __da>::value;
public:
static const intmax_t num = __s * __na / __gcd;
static const intmax_t den = __da / __gcd;
typedef ratio<num, den> type;
};
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num;
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den;
template <class T> struct __is_ratio : false_type {};
template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type {};
typedef ratio<1LL, 1000000000000000000LL> atto;
typedef ratio<1LL, 1000000000000000LL> femto;
typedef ratio<1LL, 1000000000000LL> pico;
typedef ratio<1LL, 1000000000LL> nano;
typedef ratio<1LL, 1000000LL> micro;
typedef ratio<1LL, 1000LL> milli;
typedef ratio<1LL, 100LL> centi;
typedef ratio<1LL, 10LL> deci;
typedef ratio< 10LL, 1LL> deca;
typedef ratio< 100LL, 1LL> hecto;
typedef ratio< 1000LL, 1LL> kilo;
typedef ratio< 1000000LL, 1LL> mega;
typedef ratio< 1000000000LL, 1LL> giga;
typedef ratio< 1000000000000LL, 1LL> tera;
typedef ratio< 1000000000000000LL, 1LL> peta;
typedef ratio<1000000000000000000LL, 1LL> exa;
template <class _R1, class _R2>
struct ratio_multiply
{
private:
static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;
static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;
public:
typedef typename ratio
<
__ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
__ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value
>::type type;
};
template <class _R1, class _R2>
struct ratio_divide
{
private:
static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
public:
typedef typename ratio
<
__ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
__ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
>::type type;
};
template <class _R1, class _R2>
struct ratio_add
{
private:
static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
public:
typedef typename ratio_multiply
<
ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
ratio
<
__ll_add
<
__ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
__ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
>::value,
_R2::den
>
>::type type;
};
template <class _R1, class _R2>
struct ratio_subtract
{
private:
static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
public:
typedef typename ratio_multiply
<
ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
ratio
<
__ll_sub
<
__ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
__ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value
>::value,
_R2::den
>
>::type type;
};
// ratio_equal
template <class _R1, class _R2>
struct ratio_equal
: public integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> {};
template <class _R1, class _R2>
struct ratio_not_equal
: public integral_constant<bool, !ratio_equal<_R1, _R2>::value> {};
// ratio_less
template <class _R1, class _R2, bool _Odd = false,
intmax_t _Q1 = _R1::num / _R1::den, intmax_t _M1 = _R1::num % _R1::den,
intmax_t _Q2 = _R2::num / _R2::den, intmax_t _M2 = _R2::num % _R2::den>
struct __ratio_less1
{
static const bool value = _Odd ? _Q2 < _Q1 : _Q1 < _Q2;
};
template <class _R1, class _R2, bool _Odd, intmax_t _Q>
struct __ratio_less1<_R1, _R2, _Odd, _Q, 0, _Q, 0>
{
static const bool value = false;
};
template <class _R1, class _R2, bool _Odd, intmax_t _Q, intmax_t _M2>
struct __ratio_less1<_R1, _R2, _Odd, _Q, 0, _Q, _M2>
{
static const bool value = !_Odd;
};
template <class _R1, class _R2, bool _Odd, intmax_t _Q, intmax_t _M1>
struct __ratio_less1<_R1, _R2, _Odd, _Q, _M1, _Q, 0>
{
static const bool value = _Odd;
};
template <class _R1, class _R2, bool _Odd, intmax_t _Q, intmax_t _M1,
intmax_t _M2>
struct __ratio_less1<_R1, _R2, _Odd, _Q, _M1, _Q, _M2>
{
static const bool value = __ratio_less1<ratio<_R1::den, _M1>,
ratio<_R2::den, _M2>, !_Odd>::value;
};
template <class _R1, class _R2, intmax_t _S1 = __static_sign<_R1::num>::value,
intmax_t _S2 = __static_sign<_R2::num>::value>
struct __ratio_less
{
static const bool value = _S1 < _S2;
};
template <class _R1, class _R2>
struct __ratio_less<_R1, _R2, 1LL, 1LL>
{
static const bool value = __ratio_less1<_R1, _R2>::value;
};
template <class _R1, class _R2>
struct __ratio_less<_R1, _R2, -1LL, -1LL>
{
static const bool value = __ratio_less1<ratio<-_R2::num, _R2::den>, ratio<-_R1::num, _R1::den> >::value;
};
template <class _R1, class _R2>
struct ratio_less
: public integral_constant<bool, __ratio_less<_R1, _R2>::value> {};
template <class _R1, class _R2>
struct ratio_less_equal
: public integral_constant<bool, !ratio_less<_R2, _R1>::value> {};
template <class _R1, class _R2>
struct ratio_greater
: public integral_constant<bool, ratio_less<_R2, _R1>::value> {};
template <class _R1, class _R2>
struct ratio_greater_equal
: public integral_constant<bool, !ratio_less<_R1, _R2>::value> {};
template <class _R1, class _R2>
struct __ratio_gcd
{
typedef ratio<__static_gcd<_R1::num, _R2::num>::value,
__static_lcm<_R1::den, _R2::den>::value> type;
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_RATIO

841
libcxx/include/set Normal file
View File

@ -0,0 +1,841 @@
// -*- C++ -*-
//===---------------------------- set -------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_SET
#define _LIBCPP_SET
/*
set synopsis
namespace std
{
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
class set
{
public:
// types:
typedef Key key_type;
typedef key_type value_type;
typedef Compare key_compare;
typedef key_compare value_compare;
typedef Allocator allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// construct/copy/destroy:
explicit set(const value_compare& comp = value_compare());
set(const value_compare& comp, const allocator_type& a);
template <class InputIterator>
set(InputIterator first, InputIterator last,
const value_compare& comp = value_compare());
template <class InputIterator>
set(InputIterator first, InputIterator last, const value_compare& comp,
const allocator_type& a);
set(const set& s);
set(set&& s);
explicit set(const allocator_type& a);
set(const set& s, const allocator_type& a);
set(set&& s, const allocator_type& a);
set(initializer_list<value_type> il, const value_compare& comp = value_compare());
set(initializer_list<value_type> il, const value_compare& comp,
const allocator_type& a);
~set();
set& operator=(const set& s);
set& operator=(set&& s);
set& operator=(initializer_list<value_type> il);
// iterators:
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
// capacity:
bool empty() const;
size_type size() const;
size_type max_size() const;
// modifiers:
template <class... Args>
pair<iterator, bool> emplace(Args&&... args);
template <class... Args>
iterator emplace_hint(const_iterator position, Args&&... args);
pair<iterator,bool> insert(const value_type& v);
pair<iterator,bool> insert(value_type&& v);
iterator insert(const_iterator position, const value_type& v);
iterator insert(const_iterator position, value_type&& v);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear();
void swap(set& s);
// observers:
allocator_type get_allocator() const;
key_compare key_comp() const;
value_compare value_comp() const;
// set operations:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
iterator upper_bound(const key_type& k);
const_iterator upper_bound(const key_type& k) const;
pair<iterator,iterator> equal_range(const key_type& k);
pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
};
template <class Key, class Compare, class Allocator>
bool
operator==(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator< (const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator!=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator> (const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator>=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator<=(const set<Key, Compare, Allocator>& x,
const set<Key, Compare, Allocator>& y);
// specialized algorithms:
template <class Key, class Compare, class Allocator>
void
swap(set<Key, Compare, Allocator>& x, set<Key, Compare, Allocator>& y);
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
class multiset
{
public:
// types:
typedef Key key_type;
typedef key_type value_type;
typedef Compare key_compare;
typedef key_compare value_compare;
typedef Allocator allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef typename allocator_type::size_type size_type;
typedef typename allocator_type::difference_type difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef implementation-defined iterator;
typedef implementation-defined const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// construct/copy/destroy:
explicit multiset(const value_compare& comp = value_compare());
multiset(const value_compare& comp, const allocator_type& a);
template <class InputIterator>
multiset(InputIterator first, InputIterator last,
const value_compare& comp = value_compare());
template <class InputIterator>
multiset(InputIterator first, InputIterator last,
const value_compare& comp, const allocator_type& a);
multiset(const multiset& s);
multiset(multiset&& s);
explicit multiset(const allocator_type& a);
multiset(const multiset& s, const allocator_type& a);
multiset(multiset&& s, const allocator_type& a);
multiset(initializer_list<value_type> il, const value_compare& comp = value_compare());
multiset(initializer_list<value_type> il, const value_compare& comp,
const allocator_type& a);
~multiset();
multiset& operator=(const multiset& s);
multiset& operator=(multiset&& s);
multiset& operator=(initializer_list<value_type> il);
// iterators:
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
const_iterator cbegin() const;
const_iterator cend() const;
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
// capacity:
bool empty() const;
size_type size() const;
size_type max_size() const;
// modifiers:
template <class... Args>
iterator emplace(Args&&... args);
template <class... Args>
iterator emplace_hint(const_iterator position, Args&&... args);
iterator insert(const value_type& v);
iterator insert(value_type&& v);
iterator insert(const_iterator position, const value_type& v);
iterator insert(const_iterator position, value_type&& v);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type> il);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear();
void swap(multiset& s);
// observers:
allocator_type get_allocator() const;
key_compare key_comp() const;
value_compare value_comp() const;
// set operations:
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
iterator upper_bound(const key_type& k);
const_iterator upper_bound(const key_type& k) const;
pair<iterator,iterator> equal_range(const key_type& k);
pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
};
template <class Key, class Compare, class Allocator>
bool
operator==(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator< (const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator!=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator> (const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator>=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
template <class Key, class Compare, class Allocator>
bool
operator<=(const multiset<Key, Compare, Allocator>& x,
const multiset<Key, Compare, Allocator>& y);
// specialized algorithms:
template <class Key, class Compare, class Allocator>
void
swap(multiset<Key, Compare, Allocator>& x, multiset<Key, Compare, Allocator>& y);
} // std
*/
#include <__config>
#include <__tree>
#include <functional>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key> >
class set
{
public:
// types:
typedef _Key key_type;
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
typedef _Allocator allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __base::__node_holder __node_holder;
__base __tree_;
public:
typedef typename __base::pointer pointer;
typedef typename __base::const_pointer const_pointer;
typedef typename __base::size_type size_type;
typedef typename __base::difference_type difference_type;
typedef typename __base::const_iterator iterator;
typedef typename __base::const_iterator const_iterator;
typedef _STD::reverse_iterator<iterator> reverse_iterator;
typedef _STD::reverse_iterator<const_iterator> const_reverse_iterator;
explicit set(const value_compare& __comp = value_compare())
: __tree_(__comp) {}
set(const value_compare& __comp, const allocator_type& __a)
: __tree_(__comp, __a) {}
template <class _InputIterator>
set(_InputIterator __f, _InputIterator __l,
const value_compare& __comp = value_compare())
: __tree_(__comp)
{
insert(__f, __l);
}
template <class _InputIterator>
set(_InputIterator __f, _InputIterator __l, const value_compare& __comp,
const allocator_type& __a)
: __tree_(__comp, __a)
{
insert(__f, __l);
}
set(const set& __s)
: __tree_(__s.__tree_)
{
insert(__s.begin(), __s.end());
}
#ifdef _LIBCPP_MOVE
set(set&& __s)
: __tree_(_STD::move(__s.__tree_)) {}
#endif
explicit set(const allocator_type& __a)
: __tree_(__a) {}
set(const set& __s, const allocator_type& __a)
: __tree_(__s.__tree_.value_comp(), __a)
{
insert(__s.begin(), __s.end());
}
#ifdef _LIBCPP_MOVE
set(set&& __s, const allocator_type& __a);
#endif
set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
: __tree_(__comp)
{
insert(__il.begin(), __il.end());
}
set(initializer_list<value_type> __il, const value_compare& __comp,
const allocator_type& __a)
: __tree_(__comp, __a)
{
insert(__il.begin(), __il.end());
}
set& operator=(initializer_list<value_type> __il)
{
__tree_.__assign_unique(__il.begin(), __il.end());
return *this;
}
#ifdef _LIBCPP_MOVE
set& operator=(set&& __s)
{
__tree_ = _STD::move(__s.__tree_);
return *this;
}
#endif
iterator begin() {return __tree_.begin();}
const_iterator begin() const {return __tree_.begin();}
iterator end() {return __tree_.end();}
const_iterator end() const {return __tree_.end();}
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());}
const_iterator cbegin() const {return begin();}
const_iterator cend() const {return end();}
const_reverse_iterator crbegin() const {return rbegin();}
const_reverse_iterator crend() const {return rend();}
bool empty() const {return __tree_.size() == 0;}
size_type size() const {return __tree_.size();}
size_type max_size() const {return __tree_.max_size();}
// modifiers:
#ifdef _LIBCPP_MOVE
template <class... _Args>
pair<iterator, bool> emplace(_Args&&... __args)
{return __tree_.__emplace_unique(_STD::forward<_Args>(__args)...);}
template <class... _Args>
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_unique(__p, _STD::forward<_Args>(__args)...);}
#endif
pair<iterator,bool> insert(const value_type& __v)
{return __tree_.__insert_unique(__v);}
#ifdef _LIBCPP_MOVE
pair<iterator,bool> insert(value_type&& __v)
{return __tree_.__insert_unique(_STD::move(__v));}
#endif
iterator insert(const_iterator __p, const value_type& __v)
{return __tree_.__insert_unique(__p, __v);}
#ifdef _LIBCPP_MOVE
iterator insert(const_iterator __p, value_type&& __v)
{return __tree_.__insert_unique(__p, _STD::move(__v));}
#endif
template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l)
{
for (const_iterator __e = cend(); __f != __l; ++__f)
__tree_.__insert_unique(__e, *__f);
}
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
size_type erase(const key_type& __k)
{return __tree_.__erase_unique(__k);}
iterator erase(const_iterator __f, const_iterator __l)
{return __tree_.erase(__f, __l);}
void clear() {__tree_.clear();}
void swap(set& __s) {__tree_.swap(__s.__tree_);}
allocator_type get_allocator() const {return __tree_.__alloc();}
key_compare key_comp() const {return __tree_.value_comp();}
value_compare value_comp() const {return __tree_.value_comp();}
// set operations:
iterator find(const key_type& __k) {return __tree_.find(__k);}
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
size_type count(const key_type& __k) const
{return __tree_.__count_unique(__k);}
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
const_iterator lower_bound(const key_type& __k) const
{return __tree_.lower_bound(__k);}
iterator upper_bound(const key_type& __k)
{return __tree_.upper_bound(__k);}
const_iterator upper_bound(const key_type& __k) const
{return __tree_.upper_bound(__k);}
pair<iterator,iterator> equal_range(const key_type& __k)
{return __tree_.__equal_range_unique(__k);}
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
{return __tree_.__equal_range_unique(__k);}
};
#ifdef _LIBCPP_MOVE
template <class _Key, class _Compare, class _Allocator>
set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
: __tree_(_STD::move(__s.__tree_), __a)
{
if (__a != __s.get_allocator())
{
const_iterator __e = cend();
while (!__s.empty())
insert(__e, _STD::move(__s.__tree_.remove(__s.begin())->__value_));
}
}
#endif
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator==(const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return __x.size() == __y.size() && _STD::equal(__x.begin(), __x.end(), __y.begin());
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator< (const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return _STD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator!=(const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return !(__x == __y);
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator> (const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return __y < __x;
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator>=(const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return !(__x < __y);
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator<=(const set<_Key, _Compare, _Allocator>& __x,
const set<_Key, _Compare, _Allocator>& __y)
{
return !(__y < __x);
}
// specialized algorithms:
template <class _Key, class _Compare, class _Allocator>
inline
void
swap(set<_Key, _Compare, _Allocator>& __x,
set<_Key, _Compare, _Allocator>& __y)
{
__x.swap(__y);
}
template <class _Key, class _Compare = less<_Key>,
class _Allocator = allocator<_Key> >
class multiset
{
public:
// types:
typedef _Key key_type;
typedef key_type value_type;
typedef _Compare key_compare;
typedef key_compare value_compare;
typedef _Allocator allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __tree<value_type, value_compare, allocator_type> __base;
typedef allocator_traits<allocator_type> __alloc_traits;
typedef typename __base::__node_holder __node_holder;
__base __tree_;
public:
typedef typename __base::pointer pointer;
typedef typename __base::const_pointer const_pointer;
typedef typename __base::size_type size_type;
typedef typename __base::difference_type difference_type;
typedef typename __base::const_iterator iterator;
typedef typename __base::const_iterator const_iterator;
typedef _STD::reverse_iterator<iterator> reverse_iterator;
typedef _STD::reverse_iterator<const_iterator> const_reverse_iterator;
// construct/copy/destroy:
explicit multiset(const value_compare& __comp = value_compare())
: __tree_(__comp) {}
multiset(const value_compare& __comp, const allocator_type& __a)
: __tree_(__comp, __a) {}
template <class _InputIterator>
multiset(_InputIterator __f, _InputIterator __l,
const value_compare& __comp = value_compare())
: __tree_(__comp)
{
insert(__f, __l);
}
template <class _InputIterator>
multiset(_InputIterator __f, _InputIterator __l,
const value_compare& __comp, const allocator_type& __a)
: __tree_(__comp, __a)
{
insert(__f, __l);
}
multiset(const multiset& __s)
: __tree_(__s.__tree_.value_comp(),
__alloc_traits::select_on_container_copy_construction(__s.__tree_.__alloc()))
{
insert(__s.begin(), __s.end());
}
#ifdef _LIBCPP_MOVE
multiset(multiset&& __s)
: __tree_(_STD::move(__s.__tree_)) {}
#endif
explicit multiset(const allocator_type& __a)
: __tree_(__a) {}
multiset(const multiset& __s, const allocator_type& __a)
: __tree_(__s.__tree_.value_comp(), __a)
{
insert(__s.begin(), __s.end());
}
#ifdef _LIBCPP_MOVE
multiset(multiset&& __s, const allocator_type& __a);
#endif
multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
: __tree_(__comp)
{
insert(__il.begin(), __il.end());
}
multiset(initializer_list<value_type> __il, const value_compare& __comp,
const allocator_type& __a)
: __tree_(__comp, __a)
{
insert(__il.begin(), __il.end());
}
multiset& operator=(initializer_list<value_type> __il)
{
__tree_.__assign_multi(__il.begin(), __il.end());
return *this;
}
#ifdef _LIBCPP_MOVE
multiset& operator=(multiset&& __s)
{
__tree_ = _STD::move(__s.__tree_);
return *this;
}
#endif
iterator begin() {return __tree_.begin();}
const_iterator begin() const {return __tree_.begin();}
iterator end() {return __tree_.end();}
const_iterator end() const {return __tree_.end();}
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());}
const_iterator cbegin() const {return begin();}
const_iterator cend() const {return end();}
const_reverse_iterator crbegin() const {return rbegin();}
const_reverse_iterator crend() const {return rend();}
bool empty() const {return __tree_.size() == 0;}
size_type size() const {return __tree_.size();}
size_type max_size() const {return __tree_.max_size();}
// modifiers:
#ifdef _LIBCPP_MOVE
template <class... _Args>
iterator emplace(_Args&&... __args)
{return __tree_.__emplace_multi(_STD::forward<_Args>(__args)...);}
template <class... _Args>
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __tree_.__emplace_hint_multi(__p, _STD::forward<_Args>(__args)...);}
#endif
iterator insert(const value_type& __v)
{return __tree_.__insert_multi(__v);}
#ifdef _LIBCPP_MOVE
iterator insert(value_type&& __v)
{return __tree_.__insert_multi(_STD::move(__v));}
#endif
iterator insert(const_iterator __p, const value_type& __v)
{return __tree_.__insert_multi(__p, __v);}
#ifdef _LIBCPP_MOVE
iterator insert(const_iterator __p, value_type&& __v)
{return __tree_.__insert_multi(_STD::move(__v));}
#endif
template <class _InputIterator>
void insert(_InputIterator __f, _InputIterator __l)
{
for (const_iterator __e = cend(); __f != __l; ++__f)
__tree_.__insert_multi(__e, *__f);
}
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
iterator erase(const_iterator __p) {return __tree_.erase(__p);}
size_type erase(const key_type& __k) {return __tree_.__erase_multi(__k);}
iterator erase(const_iterator __f, const_iterator __l)
{return __tree_.erase(__f, __l);}
void clear() {__tree_.clear();}
void swap(multiset& __s) {__tree_.swap(__s.__tree_);}
allocator_type get_allocator() const {return __tree_.__alloc();}
key_compare key_comp() const {return __tree_.value_comp();}
value_compare value_comp() const {return __tree_.value_comp();}
// set operations:
iterator find(const key_type& __k) {return __tree_.find(__k);}
const_iterator find(const key_type& __k) const {return __tree_.find(__k);}
size_type count(const key_type& __k) const
{return __tree_.__count_multi(__k);}
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
const_iterator lower_bound(const key_type& __k) const
{return __tree_.lower_bound(__k);}
iterator upper_bound(const key_type& __k)
{return __tree_.upper_bound(__k);}
const_iterator upper_bound(const key_type& __k) const
{return __tree_.upper_bound(__k);}
pair<iterator,iterator> equal_range(const key_type& __k)
{return __tree_.__equal_range_multi(__k);}
pair<const_iterator,const_iterator> equal_range(const key_type& __k) const
{return __tree_.__equal_range_multi(__k);}
};
#ifdef _LIBCPP_MOVE
template <class _Key, class _Compare, class _Allocator>
multiset<_Key, _Compare, _Allocator>::multiset(multiset&& __s, const allocator_type& __a)
: __tree_(_STD::move(__s.__tree_), __a)
{
if (__a != __s.get_allocator())
{
const_iterator __e = cend();
while (!__s.empty())
insert(__e, _STD::move(__s.__tree_.remove(__s.begin())->__value_));
}
}
#endif
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator==(const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return __x.size() == __y.size() && _STD::equal(__x.begin(), __x.end(), __y.begin());
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator< (const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return _STD::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator!=(const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return !(__x == __y);
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator> (const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return __y < __x;
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator>=(const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return !(__x < __y);
}
template <class _Key, class _Compare, class _Allocator>
inline
bool
operator<=(const multiset<_Key, _Compare, _Allocator>& __x,
const multiset<_Key, _Compare, _Allocator>& __y)
{
return !(__y < __x);
}
template <class _Key, class _Compare, class _Allocator>
inline
void
swap(multiset<_Key, _Compare, _Allocator>& __x,
multiset<_Key, _Compare, _Allocator>& __y)
{
__x.swap(__y);
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_SET

884
libcxx/include/sstream Normal file
View File

@ -0,0 +1,884 @@
// -*- C++ -*-
//===--------------------------- sstream ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_SSTREAM
#define _LIBCPP_SSTREAM
/*
sstream synopsis
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringbuf
: public basic_streambuf<charT, traits>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
// 27.8.1.1 Constructors:
explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::in | ios_base::out);
basic_stringbuf(basic_stringbuf&& rhs);
// 27.8.1.2 Assign and swap:
basic_stringbuf& operator=(basic_stringbuf&& rhs);
void swap(basic_stringbuf& rhs);
// 27.8.1.3 Get and set:
basic_string<char_type, traits_type, allocator_type> str() const;
void str(const basic_string<char_type, traits_type, allocator_type>& s);
protected:
// 27.8.1.4 Overridden virtual functions:
virtual int_type underflow();
virtual int_type pbackfail(int_type c = traits_type::eof());
virtual int_type overflow (int_type c = traits_type::eof());
virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out);
};
template <class charT, class traits, class Allocator>
void swap(basic_stringbuf<charT, traits, Allocator>& x,
basic_stringbuf<charT, traits, Allocator>& y);
typedef basic_stringbuf<char> stringbuf;
typedef basic_stringbuf<wchar_t> wstringbuf;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_istringstream
: public basic_istream<charT, traits>
{
public:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
// 27.8.2.1 Constructors:
explicit basic_istringstream(ios_base::openmode which = ios_base::in);
explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
ios_base::openmode which = ios_base::in);
basic_istringstream(basic_istringstream&& rhs);
// 27.8.2.2 Assign and swap:
basic_istringstream& operator=(basic_istringstream&& rhs);
void swap(basic_istringstream& rhs);
// 27.8.2.3 Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
basic_string<char_type, traits_type, allocator_type> str() const;
void str(const basic_string<char_type, traits_type, allocator_type>& s);
};
template <class charT, class traits, class Allocator>
void swap(basic_istringstream<charT, traits, Allocator>& x,
basic_istringstream<charT, traits, Allocator>& y);
typedef basic_istringstream<char> istringstream;
typedef basic_istringstream<wchar_t> wistringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_ostringstream
: public basic_ostream<charT, traits>
{
public:
// types:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
// 27.8.3.1 Constructors/destructor:
explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::out);
basic_ostringstream(basic_ostringstream&& rhs);
// 27.8.3.2 Assign/swap:
basic_ostringstream& operator=(basic_ostringstream&& rhs);
void swap(basic_ostringstream& rhs);
// 27.8.3.3 Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
basic_string<char_type, traits_type, allocator_type> str() const;
void str(const basic_string<char_type, traits_type, allocator_type>& s);
};
template <class charT, class traits, class Allocator>
void swap(basic_ostringstream<charT, traits, Allocator>& x,
basic_ostringstream<charT, traits, Allocator>& y);
typedef basic_ostringstream<char> ostringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringstream
: public basic_iostream<charT, traits>
{
public:
// types:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef Allocator allocator_type;
// constructors/destructor
explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
ios_base::openmode which = ios_base::out|ios_base::in);
basic_stringstream(basic_stringstream&& rhs);
// 27.8.5.1 Assign/swap:
basic_stringstream& operator=(basic_stringstream&& rhs);
void swap(basic_stringstream& rhs);
// Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
basic_string<char_type, traits_type, allocator_type> str() const;
void str(const basic_string<char_type, traits_type, allocator_type>& str);
};
template <class charT, class traits, class Allocator>
void swap(basic_stringstream<charT, traits, Allocator>& x,
basic_stringstream<charT, traits, Allocator>& y);
typedef basic_stringstream<char> stringstream;
typedef basic_stringstream<wchar_t> wstringstream;
} // std
*/
#include <__config>
#include <ostream>
#include <istream>
#include <string>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
// basic_stringbuf
template <class _CharT, class _Traits, class _Allocator>
class basic_stringbuf
: public basic_streambuf<_CharT, _Traits>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef _Allocator allocator_type;
typedef basic_string<char_type, traits_type, allocator_type> string_type;
private:
string_type __str_;
mutable char_type* __hm_;
ios_base::openmode __mode_;
public:
// 27.8.1.1 Constructors:
explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
explicit basic_stringbuf(const string_type& __s,
ios_base::openmode __wch = ios_base::in | ios_base::out);
#ifdef _LIBCPP_MOVE
basic_stringbuf(basic_stringbuf&& __rhs);
#endif
// 27.8.1.2 Assign and swap:
#ifdef _LIBCPP_MOVE
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
#endif
void swap(basic_stringbuf& __rhs);
// 27.8.1.3 Get and set:
string_type str() const;
void str(const string_type& __s);
protected:
// 27.8.1.4 Overridden virtual functions:
virtual int_type underflow();
virtual int_type pbackfail(int_type __c = traits_type::eof());
virtual int_type overflow (int_type __c = traits_type::eof());
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __wch = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type __sp,
ios_base::openmode __wch = ios_base::in | ios_base::out);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
: __hm_(0),
__mode_(__wch)
{
str(string_type());
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
ios_base::openmode __wch)
: __hm_(0),
__mode_(__wch)
{
str(__s);
}
#ifdef _LIBCPP_MOVE
template <class _CharT, class _Traits, class _Allocator>
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
: __mode_(__rhs.__mode_)
{
ptrdiff_t __ninp = __rhs.gptr() - __rhs.eback();
ptrdiff_t __einp = __rhs.egptr() - __rhs.eback();
ptrdiff_t __nout = __rhs.pptr() - __rhs.pbase();
ptrdiff_t __eout = __rhs.epptr() - __rhs.pbase();
ptrdiff_t __hm = __rhs.__hm_ - __rhs.pbase();
__str_ = _STD::move(__rhs.__str_);
char_type* __p = const_cast<char_type*>(__str_.data());
this->setg(__p, __p + __ninp, __p + __einp);
this->setp(__p, __p + __eout);
this->pbump(__nout);
__hm_ = __p + __hm;
__p = const_cast<char_type*>(__rhs.__str_.data());
__rhs.setg(__p, __p, __p);
__rhs.setp(__p, __p);
__rhs.__hm_ = __p;
this->pubimbue(__rhs.getloc());
}
template <class _CharT, class _Traits, class _Allocator>
basic_stringbuf<_CharT, _Traits, _Allocator>&
basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
{
ptrdiff_t __ninp = __rhs.gptr() - __rhs.eback();
ptrdiff_t __einp = __rhs.egptr() - __rhs.eback();
ptrdiff_t __nout = __rhs.pptr() - __rhs.pbase();
ptrdiff_t __eout = __rhs.epptr() - __rhs.pbase();
ptrdiff_t __hm = __rhs.__hm_ - __rhs.pbase();
__mode_ = __rhs.__mode_;
__str_ = _STD::move(__rhs.__str_);
char_type* __p = const_cast<char_type*>(__str_.data());
this->setg(__p, __p + __ninp, __p + __einp);
this->setp(__p, __p + __eout);
this->pbump(__nout);
__hm_ = __p + __hm;
__p = const_cast<char_type*>(__rhs.__str_.data());
__rhs.setg(__p, __p, __p);
__rhs.setp(__p, __p);
__rhs.__hm_ = __p;
this->pubimbue(__rhs.getloc());
return *this;
}
#endif
template <class _CharT, class _Traits, class _Allocator>
void
basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
{
ptrdiff_t __rninp = __rhs.gptr() - __rhs.eback();
ptrdiff_t __reinp = __rhs.egptr() - __rhs.eback();
ptrdiff_t __rnout = __rhs.pptr() - __rhs.pbase();
ptrdiff_t __reout = __rhs.epptr() - __rhs.pbase();
ptrdiff_t __rhm = __rhs.__hm_ - __rhs.pbase();
ptrdiff_t __lninp = this->gptr() - this->eback();
ptrdiff_t __leinp = this->egptr() - this->eback();
ptrdiff_t __lnout = this->pptr() - this->pbase();
ptrdiff_t __leout = this->epptr() - this->pbase();
ptrdiff_t __lhm = this->__hm_ - this->pbase();
_STD::swap(__mode_, __rhs.__mode_);
__str_.swap(__rhs.__str_);
char_type* __p = const_cast<char_type*>(__str_.data());
this->setg(__p, __p + __rninp, __p + __reinp);
this->setp(__p, __p + __reout);
this->pbump(__rnout);
__hm_ = __p + __rhm;
__p = const_cast<char_type*>(__rhs.__str_.data());
__rhs.setg(__p, __p + __lninp, __p + __leinp);
__rhs.setp(__p, __p + __leout);
__rhs.pbump(__lnout);
__rhs.__hm_ = __p + __lhm;
locale __tl = __rhs.getloc();
__rhs.pubimbue(this->getloc());
this->pubimbue(__tl);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
{
__x.swap(__y);
}
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator>
basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
{
if (__mode_ & ios_base::out)
{
if (__hm_ < this->pptr())
__hm_ = this->pptr();
return string_type(this->pbase(), __hm_, __str_.get_allocator());
}
else if (__mode_ & ios_base::in)
return string_type(this->eback(), this->egptr(), __str_.get_allocator());
return string_type(__str_.get_allocator());
}
template <class _CharT, class _Traits, class _Allocator>
void
basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__str_ = __s;
__hm_ = 0;
if (__mode_ & ios_base::in)
{
__hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
this->setg(const_cast<char_type*>(__str_.data()),
const_cast<char_type*>(__str_.data()),
__hm_);
}
if (__mode_ & ios_base::out)
{
typename string_type::size_type __sz = __str_.size();
__hm_ = const_cast<char_type*>(__str_.data()) + __sz;
__str_.resize(__str_.capacity());
this->setp(const_cast<char_type*>(__str_.data()),
const_cast<char_type*>(__str_.data()) + __str_.size());
if (__mode_ & (ios_base::app | ios_base::ate))
this->pbump(__sz);
}
}
template <class _CharT, class _Traits, class _Allocator>
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
{
if (__hm_ < this->pptr())
__hm_ = this->pptr();
if (__mode_ & ios_base::in)
{
if (this->egptr() < __hm_)
this->setg(this->eback(), this->gptr(), __hm_);
if (this->gptr() < this->egptr())
return traits_type::to_int_type(*this->gptr());
}
return traits_type::eof();
}
template <class _CharT, class _Traits, class _Allocator>
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
{
if (__hm_ < this->pptr())
__hm_ = this->pptr();
if (this->eback() < this->gptr())
{
if (traits_type::eq_int_type(__c, traits_type::eof()))
{
this->setg(this->eback(), this->gptr()-1, __hm_);
return traits_type::not_eof(__c);
}
if ((__mode_ & ios_base::out) ||
traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
{
this->setg(this->eback(), this->gptr()-1, __hm_);
*this->gptr() = traits_type::to_char_type(__c);
return __c;
}
}
return traits_type::eof();
}
template <class _CharT, class _Traits, class _Allocator>
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
{
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
ptrdiff_t __ninp = this->gptr() - this->eback();
if (this->pptr() == this->epptr())
{
if (!(__mode_ & ios_base::out))
return traits_type::eof();
#ifndef _LIBCPP_NO_EXCEPTIONS
try
{
#endif
ptrdiff_t __nout = this->pptr() - this->pbase();
ptrdiff_t __hm = __hm_ - this->pbase();
__str_.push_back(char_type());
__str_.resize(__str_.capacity());
char_type* __p = const_cast<char_type*>(__str_.data());
this->setp(__p, __p + __str_.size());
this->pbump(__nout);
__hm_ = this->pbase() + __hm;
#ifndef _LIBCPP_NO_EXCEPTIONS
}
catch (...)
{
return traits_type::eof();
}
#endif
}
__hm_ = max(this->pptr() + 1, __hm_);
if (__mode_ & ios_base::in)
{
char_type* __p = const_cast<char_type*>(__str_.data());
this->setg(__p, __p + __ninp, __hm_);
}
return this->sputc(__c);
}
return traits_type::not_eof(__c);
}
template <class _CharT, class _Traits, class _Allocator>
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
ios_base::seekdir __way,
ios_base::openmode __wch)
{
if (__hm_ < this->pptr())
__hm_ = this->pptr();
if ((__wch & (ios_base::in | ios_base::out)) == 0)
return pos_type(-1);
if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
&& __way == ios_base::cur)
return pos_type(-1);
off_type __noff;
switch (__way)
{
case ios_base::beg:
__noff = 0;
break;
case ios_base::cur:
if (__wch & ios_base::in)
__noff = this->gptr() - this->eback();
else
__noff = this->pptr() - this->pbase();
break;
case ios_base::end:
__noff = __hm_ - __str_.data();
break;
default:
return pos_type(-1);
}
__noff += __off;
if (__noff < 0 || __hm_ - __str_.data() < __noff)
return pos_type(-1);
if (__noff != 0)
{
if ((__wch & ios_base::in) && this->gptr() == 0)
return pos_type(-1);
if ((__wch & ios_base::out) && this->pptr() == 0)
return pos_type(-1);
}
if (__wch & ios_base::in)
this->setg(this->eback(), this->eback() + __noff, __hm_);
if (__wch & ios_base::out)
{
this->setp(this->pbase(), this->epptr());
this->pbump(__noff);
}
return pos_type(__noff);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
ios_base::openmode __wch)
{
return seekoff(__sp, ios_base::beg, __wch);
}
// basic_istringstream
template <class _CharT, class _Traits, class _Allocator>
class basic_istringstream
: public basic_istream<_CharT, _Traits>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef _Allocator allocator_type;
typedef basic_string<char_type, traits_type, allocator_type> string_type;
private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
// 27.8.2.1 Constructors:
explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
explicit basic_istringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::in);
#ifdef _LIBCPP_MOVE
basic_istringstream(basic_istringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_istringstream& operator=(basic_istringstream&& __rhs);
#endif
void swap(basic_istringstream& __rhs);
// 27.8.2.3 Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
string_type str() const;
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
: basic_istream<_CharT, _Traits>(&__sb_),
__sb_(__wch | ios_base::in)
{
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_istream<_CharT, _Traits>(&__sb_),
__sb_(__s, __wch | ios_base::in)
{
}
#ifdef _LIBCPP_MOVE
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
: basic_istream<_CharT, _Traits>(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
basic_istringstream<_CharT, _Traits, _Allocator>&
basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
{
basic_istream<char_type, traits_type>::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
{
basic_istream<char_type, traits_type>::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
basic_istringstream<_CharT, _Traits, _Allocator>& __y)
{
__x.swap(__y);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_istringstream<_CharT, _Traits, _Allocator>::str() const
{
return __sb_.str();
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__sb_.str(__s);
}
// basic_ostringstream
template <class _CharT, class _Traits, class _Allocator>
class basic_ostringstream
: public basic_ostream<_CharT, _Traits>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef _Allocator allocator_type;
typedef basic_string<char_type, traits_type, allocator_type> string_type;
private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
// 27.8.2.1 Constructors:
explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
explicit basic_ostringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::out);
#ifdef _LIBCPP_MOVE
basic_ostringstream(basic_ostringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_ostringstream& operator=(basic_ostringstream&& __rhs);
#endif
void swap(basic_ostringstream& __rhs);
// 27.8.2.3 Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
string_type str() const;
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
: basic_ostream<_CharT, _Traits>(&__sb_),
__sb_(__wch | ios_base::out)
{
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_ostream<_CharT, _Traits>(&__sb_),
__sb_(__s, __wch | ios_base::out)
{
}
#ifdef _LIBCPP_MOVE
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
: basic_ostream<_CharT, _Traits>(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
basic_ostringstream<_CharT, _Traits, _Allocator>&
basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
{
basic_ostream<char_type, traits_type>::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
{
basic_ostream<char_type, traits_type>::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
{
__x.swap(__y);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
{
return __sb_.str();
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__sb_.str(__s);
}
// basic_stringstream
template <class _CharT, class _Traits, class _Allocator>
class basic_stringstream
: public basic_iostream<_CharT, _Traits>
{
public:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
typedef _Allocator allocator_type;
typedef basic_string<char_type, traits_type, allocator_type> string_type;
private:
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
public:
// 27.8.2.1 Constructors:
explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
explicit basic_stringstream(const string_type& __s,
ios_base::openmode __wch = ios_base::in | ios_base::out);
#ifdef _LIBCPP_MOVE
basic_stringstream(basic_stringstream&& __rhs);
// 27.8.2.2 Assign and swap:
basic_stringstream& operator=(basic_stringstream&& __rhs);
#endif
void swap(basic_stringstream& __rhs);
// 27.8.2.3 Members:
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
string_type str() const;
void str(const string_type& __s);
};
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
: basic_iostream<_CharT, _Traits>(&__sb_),
__sb_(__wch)
{
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
ios_base::openmode __wch)
: basic_iostream<_CharT, _Traits>(&__sb_),
__sb_(__s, __wch)
{
}
#ifdef _LIBCPP_MOVE
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
: basic_iostream<_CharT, _Traits>(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
basic_stringstream<_CharT, _Traits, _Allocator>&
basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
{
basic_iostream<char_type, traits_type>::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
{
basic_iostream<char_type, traits_type>::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
basic_stringstream<_CharT, _Traits, _Allocator>& __y)
{
__x.swap(__y);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_stringbuf<_CharT, _Traits, _Allocator>*
basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
{
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
basic_string<_CharT, _Traits, _Allocator>
basic_stringstream<_CharT, _Traits, _Allocator>::str() const
{
return __sb_.str();
}
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
{
__sb_.str(__s);
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_SSTREAM

237
libcxx/include/stack Normal file
View File

@ -0,0 +1,237 @@
// -*- C++ -*-
//===---------------------------- stack -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STACK
#define _LIBCPP_STACK
/*
stack synopsis
namespace std
{
template <class T, class Container = deque<T>>
class stack
{
public:
typedef Container container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
public:
explicit stack();
explicit stack(const container_type& c);
explicit stack(container_type&& c);
stack(stack&& s);
stack& operator=(stack&& s);
template <class Alloc> explicit stack(const Alloc& a);
template <class Alloc> stack(const container_type& c, const Alloc& a);
template <class Alloc> stack(container_type&& c, const Alloc& a);
template <class Alloc> stack(stack&& c, const Alloc& a);
bool empty() const;
size_type size() const;
reference top();
const_reference top() const;
void push(const value_type& x);
void push(value_type&& x);
template <class... Args> void emplace(Args&&... args);
void pop();
void swap(stack& c);
};
template <class T, class Container>
bool operator==(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator< (const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator!=(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator> (const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator>=(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
bool operator<=(const stack<T, Container>& x, const stack<T, Container>& y);
template <class T, class Container>
void swap(stack<T, Container>& x, stack<T, Container>& y);
} // std
*/
#include <__config>
#include <deque>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Container> class stack;
template <class _Tp, class _Container>
bool
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
template <class _Tp, class _Container>
bool
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
template <class _Tp, class _Container = deque<_Tp> >
class stack
{
public:
typedef _Container container_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
typedef typename container_type::const_reference const_reference;
typedef typename container_type::size_type size_type;
protected:
container_type c;
public:
stack() : c() {}
explicit stack(const container_type& __c) : c(__c) {}
#ifdef _LIBCPP_MOVE
explicit stack(container_type&& __c) : c(_STD::move(__c)) {}
stack(stack&& __s) : c(_STD::move(__s.c)) {}
stack& operator=(stack&& __s) {c = _STD::move(__s.c); return *this;}
#endif
template <class _Alloc>
explicit stack(const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__a) {}
template <class _Alloc>
stack(const container_type& __c, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__c, __a) {}
template <class _Alloc>
stack(const stack& __s, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(__s.c, __a) {}
#ifdef _LIBCPP_MOVE
template <class _Alloc>
stack(container_type&& __c, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(_STD::move(__c), __a) {}
template <class _Alloc>
stack(stack&& __s, const _Alloc& __a,
typename enable_if<uses_allocator<container_type,
_Alloc>::value>::type* = 0)
: c(_STD::move(__s.c), __a) {}
#endif
bool empty() const {return c.empty();}
size_type size() const {return c.size();}
reference top() {return c.back();}
const_reference top() const {return c.back();}
void push(const value_type& __v) {c.push_back(__v);}
#ifdef _LIBCPP_MOVE
void push(value_type&& __v) {c.push_back(_STD::move(__v));}
template <class... _Args> void emplace(_Args&&... __args)
{c.emplace_back(_STD::forward<_Args>(__args)...);}
#endif
void pop() {c.pop_back();}
void swap(stack& __s)
{
using _STD::swap;
swap(c, __s.c);
}
template <class T1, class _C1>
friend
bool
operator==(const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
template <class T1, class _C1>
friend
bool
operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y);
};
template <class _Tp, class _Container>
inline
bool
operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return __x.c == __y.c;
}
template <class _Tp, class _Container>
inline
bool
operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return __x.c < __y.c;
}
template <class _Tp, class _Container>
inline
bool
operator!=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return !(__x == __y);
}
template <class _Tp, class _Container>
inline
bool
operator> (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return __y < __x;
}
template <class _Tp, class _Container>
inline
bool
operator>=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return !(__x < __y);
}
template <class _Tp, class _Container>
inline
bool
operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y)
{
return !(__y < __x);
}
template <class _Tp, class _Container>
inline
void
swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
{
__x.swap(__y);
}
template <class _Tp, class _Container, class _Alloc>
struct uses_allocator<stack<_Tp, _Container>, _Alloc>
: public uses_allocator<_Container, _Alloc>
{
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STACK

44
libcxx/include/stdbool.h Normal file
View File

@ -0,0 +1,44 @@
// -*- C++ -*-
//===--------------------------- stdbool.h --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STDBOOL_H
#define _LIBCPP_STDBOOL_H
/*
stdbool.h synopsis
Macros:
__bool_true_false_are_defined
*/
#ifdef __cplusplus
#include <__config>
#endif
#pragma GCC system_header
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1
#ifndef __cplusplus
#define bool _Bool
#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
typedef int _Bool;
#endif
#define false (bool)0
#define true (bool)1
#endif /* !__cplusplus */
#endif // _LIBCPP_STDBOOL_H

161
libcxx/include/stdexcept Normal file
View File

@ -0,0 +1,161 @@
// -*- C++ -*-
//===--------------------------- stdexcept --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STDEXCEPT
#define _LIBCPP_STDEXCEPT
/*
stdexcept synopsis
namespace std
{
class logic_error;
class domain_error;
class invalid_argument;
class length_error;
class out_of_range;
class runtime_error;
class range_error;
class overflow_error;
class underflow_error;
for each class xxx_error:
class xxx_error : public exception // at least indirectly
{
public:
explicit xxx_error(const string& what_arg);
explicit xxx_error(const char* what_arg); // extension
virtual const char* what() const // returns what_arg
};
} // std
*/
#include <__config>
#include <exception>
#include <iosfwd> // for string forward decl
#pragma GCC system_header
namespace std // purposefully not using versioning namespace
{
class _LIBCPP_EXCEPTION_ABI logic_error
: public exception
{
private:
void* __imp_;
public:
explicit logic_error(const string&);
explicit logic_error(const char*);
logic_error(const logic_error&) throw();
logic_error& operator=(const logic_error&) throw();
virtual ~logic_error() throw();
virtual const char* what() const throw();
};
class _LIBCPP_EXCEPTION_ABI runtime_error
: public exception
{
private:
void* __imp_;
public:
explicit runtime_error(const string&);
explicit runtime_error(const char*);
runtime_error(const runtime_error&) throw();
runtime_error& operator=(const runtime_error&) throw();
virtual ~runtime_error() throw();
virtual const char* what() const throw();
};
class _LIBCPP_EXCEPTION_ABI domain_error
: public logic_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {}
virtual ~domain_error() throw();
};
class _LIBCPP_EXCEPTION_ABI invalid_argument
: public logic_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {}
virtual ~invalid_argument() throw();
};
class _LIBCPP_EXCEPTION_ABI length_error
: public logic_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
virtual ~length_error() throw();
};
class _LIBCPP_EXCEPTION_ABI out_of_range
: public logic_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {}
virtual ~out_of_range() throw();
};
class _LIBCPP_EXCEPTION_ABI range_error
: public runtime_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {}
virtual ~range_error() throw();
};
class _LIBCPP_EXCEPTION_ABI overflow_error
: public runtime_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {}
virtual ~overflow_error() throw();
};
class _LIBCPP_EXCEPTION_ABI underflow_error
: public runtime_error
{
public:
_LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}
_LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {}
virtual ~underflow_error() throw();
};
} // std
#endif // _LIBCPP_STDEXCEPT

563
libcxx/include/streambuf Normal file
View File

@ -0,0 +1,563 @@
// -*- C++ -*-
//===------------------------- streambuf ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STEAMBUF
#define _LIBCPP_STEAMBUF
/*
streambuf synopsis
namespace std
{
template <class charT, class traits = char_traits<charT> >
class basic_streambuf
{
public:
// types:
typedef charT char_type;
typedef traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
virtual ~basic_streambuf();
// 27.6.2.2.1 locales:
locale pubimbue(const locale& loc);
locale getloc() const;
// 27.6.2.2.2 buffer and positioning:
basic_streambuf* pubsetbuf(char_type* s, streamsize n);
pos_type pubseekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
pos_type pubseekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out);
int pubsync();
// Get and put areas:
// 27.6.2.2.3 Get area:
streamsize in_avail();
int_type snextc();
int_type sbumpc();
int_type sgetc();
streamsize sgetn(char_type* s, streamsize n);
// 27.6.2.2.4 Putback:
int_type sputbackc(char_type c);
int_type sungetc();
// 27.6.2.2.5 Put area:
int_type sputc(char_type c);
streamsize sputn(const char_type* s, streamsize n);
protected:
basic_streambuf();
basic_streambuf(const basic_streambuf& rhs);
basic_streambuf& operator=(const basic_streambuf& rhs);
void swap(basic_streambuf& rhs);
// 27.6.2.3.2 Get area:
char_type* eback() const;
char_type* gptr() const;
char_type* egptr() const;
void gbump(int n);
void setg(char_type* gbeg, char_type* gnext, char_type* gend);
// 27.6.2.3.3 Put area:
char_type* pbase() const;
char_type* pptr() const;
char_type* epptr() const;
void pbump(int n);
void setp(char_type* pbeg, char_type* pend);
// 27.6.2.4 virtual functions:
// 27.6.2.4.1 Locales:
virtual void imbue(const locale& loc);
// 27.6.2.4.2 Buffer management and positioning:
virtual basic_streambuf* setbuf(char_type* s, streamsize n);
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out);
virtual int sync();
// 27.6.2.4.3 Get area:
virtual streamsize showmanyc();
virtual streamsize xsgetn(char_type* s, streamsize n);
virtual int_type underflow();
virtual int_type uflow();
// 27.6.2.4.4 Putback:
virtual int_type pbackfail(int_type c = traits_type::eof());
// 27.6.2.4.5 Put area:
virtual streamsize xsputn(const char_type* s, streamsize n);
virtual int_type overflow (int_type c = traits_type::eof());
};
} // std
*/
#include <__config>
#include <iosfwd>
#include <ios>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _CharT, class _Traits>
class basic_streambuf
{
public:
// types:
typedef _CharT char_type;
typedef _Traits traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
virtual ~basic_streambuf();
// 27.6.2.2.1 locales:
locale pubimbue(const locale& __loc);
locale getloc() const;
// 27.6.2.2.2 buffer and positioning:
basic_streambuf* pubsetbuf(char_type* __s, streamsize __n);
pos_type pubseekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __which = ios_base::in | ios_base::out);
pos_type pubseekpos(pos_type __sp,
ios_base::openmode __which = ios_base::in | ios_base::out);
int pubsync();
// Get and put areas:
// 27.6.2.2.3 Get area:
streamsize in_avail();
int_type snextc();
int_type sbumpc();
int_type sgetc();
streamsize sgetn(char_type* __s, streamsize __n);
// 27.6.2.2.4 Putback:
int_type sputbackc(char_type __c);
int_type sungetc();
// 27.6.2.2.5 Put area:
int_type sputc(char_type __c);
streamsize sputn(const char_type* __s, streamsize __n);
protected:
basic_streambuf();
basic_streambuf(const basic_streambuf& __rhs);
basic_streambuf& operator=(const basic_streambuf& __rhs);
void swap(basic_streambuf& __rhs);
// 27.6.2.3.2 Get area:
_LIBCPP_ALWAYS_INLINE char_type* eback() const {return __binp_;}
_LIBCPP_ALWAYS_INLINE char_type* gptr() const {return __ninp_;}
_LIBCPP_ALWAYS_INLINE char_type* egptr() const {return __einp_;}
void gbump(int __n);
void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend);
// 27.6.2.3.3 Put area:
_LIBCPP_ALWAYS_INLINE char_type* pbase() const {return __bout_;}
_LIBCPP_ALWAYS_INLINE char_type* pptr() const {return __nout_;}
_LIBCPP_ALWAYS_INLINE char_type* epptr() const {return __eout_;}
void pbump(int __n);
void setp(char_type* __pbeg, char_type* __pend);
// 27.6.2.4 virtual functions:
// 27.6.2.4.1 Locales:
virtual void imbue(const locale& __loc);
// 27.6.2.4.2 Buffer management and positioning:
virtual basic_streambuf* setbuf(char_type* __s, streamsize __n);
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __which = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type __sp,
ios_base::openmode __which = ios_base::in | ios_base::out);
virtual int sync();
// 27.6.2.4.3 Get area:
virtual streamsize showmanyc();
virtual streamsize xsgetn(char_type* __s, streamsize __n);
virtual int_type underflow();
virtual int_type uflow();
// 27.6.2.4.4 Putback:
virtual int_type pbackfail(int_type __c = traits_type::eof());
// 27.6.2.4.5 Put area:
virtual streamsize xsputn(const char_type* __s, streamsize __n);
virtual int_type overflow(int_type __c = traits_type::eof());
private:
locale __loc_;
char_type* __binp_;
char_type* __ninp_;
char_type* __einp_;
char_type* __bout_;
char_type* __nout_;
char_type* __eout_;
};
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::~basic_streambuf()
{
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
locale
basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc)
{
imbue(__loc);
locale __r = __loc_;
__loc_ = __loc;
return __r;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
locale
basic_streambuf<_CharT, _Traits>::getloc() const
{
return __loc_;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
basic_streambuf<_CharT, _Traits>*
basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n)
{
return setbuf(__s, __n);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off,
ios_base::seekdir __way,
ios_base::openmode __which)
{
return seekoff(__off, __way, __which);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp,
ios_base::openmode __which)
{
return seekpos(__sp, __which);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
int
basic_streambuf<_CharT, _Traits>::pubsync()
{
return sync();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::in_avail()
{
if (__ninp_ < __einp_)
return static_cast<streamsize>(__einp_ - __ninp_);
return showmanyc();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::snextc()
{
if (sbumpc() == traits_type::eof())
return traits_type::eof();
return sgetc();
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sbumpc()
{
if (__ninp_ == __einp_)
return uflow();
return traits_type::to_int_type(*__ninp_++);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sgetc()
{
if (__ninp_ == __einp_)
return underflow();
return traits_type::to_int_type(*__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n)
{
return xsgetn(__s, __n);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c)
{
if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
return pbackfail(traits_type::to_int_type(__c));
return traits_type::to_int_type(*--__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sungetc()
{
if (__binp_ == __ninp_)
return pbackfail();
return traits_type::to_int_type(*--__ninp_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::sputc(char_type __c)
{
if (__nout_ == __eout_)
return overflow(traits_type::to_int_type(__c));
*__nout_++ = __c;
return traits_type::to_int_type(__c);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
streamsize
basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n)
{
return xsputn(__s, __n);
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::basic_streambuf()
: __binp_(0),
__ninp_(0),
__einp_(0),
__bout_(0),
__nout_(0),
__eout_(0)
{
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb)
: __loc_(__sb.__loc_),
__binp_(__sb.__binp_),
__ninp_(__sb.__ninp_),
__einp_(__sb.__einp_),
__bout_(__sb.__bout_),
__nout_(__sb.__nout_),
__eout_(__sb.__eout_)
{
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>&
basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb)
{
__loc_ = __sb.__loc_;
__binp_ = __sb.__binp_;
__ninp_ = __sb.__ninp_;
__einp_ = __sb.__einp_;
__bout_ = __sb.__bout_;
__nout_ = __sb.__nout_;
__eout_ = __sb.__eout_;
return *this;
}
template <class _CharT, class _Traits>
void
basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb)
{
_STD::swap(__loc_, __sb.__loc_);
_STD::swap(__binp_, __sb.__binp_);
_STD::swap(__ninp_, __sb.__ninp_);
_STD::swap(__einp_, __sb.__einp_);
_STD::swap(__bout_, __sb.__bout_);
_STD::swap(__nout_, __sb.__nout_);
_STD::swap(__eout_, __sb.__eout_);
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::gbump(int __n)
{
__ninp_ += __n;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext,
char_type* __gend)
{
__binp_ = __gbeg;
__ninp_ = __gnext;
__einp_ = __gend;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::pbump(int __n)
{
__nout_ += __n;
}
template <class _CharT, class _Traits>
inline _LIBCPP_INLINE_VISIBILITY
void
basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend)
{
__bout_ = __nout_ = __pbeg;
__eout_ = __pend;
}
template <class _CharT, class _Traits>
void
basic_streambuf<_CharT, _Traits>::imbue(const locale&)
{
}
template <class _CharT, class _Traits>
basic_streambuf<_CharT, _Traits>*
basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize)
{
return this;
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __which)
{
return pos_type(off_type(-1));
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::pos_type
basic_streambuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode __which)
{
return pos_type(off_type(-1));
}
template <class _CharT, class _Traits>
int
basic_streambuf<_CharT, _Traits>::sync()
{
return 0;
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::showmanyc()
{
return 0;
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
{
const int_type __eof = traits_type::eof();
int_type __c;
streamsize __i = 0;
for (;__i < __n; ++__i, ++__s)
{
if (__ninp_ < __einp_)
*__s = *__ninp_++;
else if ((__c = uflow()) != __eof)
*__s = traits_type::to_char_type(__c);
else
break;
}
return __i;
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::underflow()
{
return traits_type::eof();
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::uflow()
{
if (underflow() == traits_type::eof())
return traits_type::eof();
return traits_type::to_int_type(*__ninp_++);
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::pbackfail(int_type)
{
return traits_type::eof();
}
template <class _CharT, class _Traits>
streamsize
basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n)
{
streamsize __i = 0;
int_type __eof = traits_type::eof();
for (; __i < __n; ++__s, ++__i)
{
if (__nout_ < __eout_)
*__nout_++ = *__s;
else if (overflow(*__s) == __eof)
break;
}
return __i;
}
template <class _CharT, class _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::overflow(int_type __c)
{
return traits_type::eof();
}
extern template class basic_streambuf<char>;
extern template class basic_streambuf<wchar_t>;
extern template class basic_ios<char>;
extern template class basic_ios<wchar_t>;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STEAMBUF

3543
libcxx/include/string Normal file

File diff suppressed because it is too large Load Diff

332
libcxx/include/strstream Normal file
View File

@ -0,0 +1,332 @@
// -*- C++ -*-
//===--------------------------- strstream --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_STRSTREAM
#define _LIBCPP_STRSTREAM
/*
strstream synopsis
class strstreambuf
: public basic_streambuf<char>
{
public:
explicit strstreambuf(streamsize alsize_arg = 0);
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
strstreambuf(strstreambuf&& rhs);
strstreambuf& operator=(strstreambuf&& rhs);
virtual ~strstreambuf();
void swap(strstreambuf& rhs);
void freeze(bool freezefl = true);
char* str();
int pcount() const;
protected:
virtual int_type overflow (int_type c = EOF);
virtual int_type pbackfail(int_type c = EOF);
virtual int_type underflow();
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type sp,
ios_base::openmode which = ios_base::in | ios_base::out);
virtual streambuf* setbuf(char* s, streamsize n);
private:
typedef T1 strstate; // exposition only
static const strstate allocated; // exposition only
static const strstate constant; // exposition only
static const strstate dynamic; // exposition only
static const strstate frozen; // exposition only
strstate strmode; // exposition only
streamsize alsize; // exposition only
void* (*palloc)(size_t); // exposition only
void (*pfree)(void*); // exposition only
};
class istrstream
: public basic_istream<char>
{
public:
explicit istrstream(const char* s);
explicit istrstream(char* s);
istrstream(const char* s, streamsize n);
istrstream(char* s, streamsize n);
virtual ~istrstream();
strstreambuf* rdbuf() const;
char *str();
private:
strstreambuf sb; // exposition only
};
class ostrstream
: public basic_ostream<char>
{
public:
ostrstream();
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
virtual ~ostrstream();
strstreambuf* rdbuf() const;
void freeze(bool freezefl = true);
char* str();
int pcount() const;
private:
strstreambuf sb; // exposition only
};
class strstream
: public basic_iostream<char>
{
public:
// Types
typedef char char_type;
typedef char_traits<char>::int_type int_type;
typedef char_traits<char>::pos_type pos_type;
typedef char_traits<char>::off_type off_type;
// constructors/destructor
strstream();
strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out);
virtual ~strstream();
// Members:
strstreambuf* rdbuf() const;
void freeze(bool freezefl = true);
int pcount() const;
char* str();
private:
strstreambuf sb; // exposition only
};
} // std
*/
#include <__config>
#include <ostream>
#include <istream>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
class strstreambuf
: public streambuf
{
public:
explicit strstreambuf(streamsize __alsize = 0);
strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0);
strstreambuf(const char* __gnext, streamsize __n);
strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0);
strstreambuf(const signed char* __gnext, streamsize __n);
strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0);
strstreambuf(const unsigned char* __gnext, streamsize __n);
#ifdef _LIBCPP_MOVE
strstreambuf(strstreambuf&& __rhs);
strstreambuf& operator=(strstreambuf&& __rhs);
#endif
virtual ~strstreambuf();
void swap(strstreambuf& __rhs);
void freeze(bool __freezefl = true);
char* str();
int pcount() const;
protected:
virtual int_type overflow (int_type __c = EOF);
virtual int_type pbackfail(int_type __c = EOF);
virtual int_type underflow();
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
ios_base::openmode __which = ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type __sp,
ios_base::openmode __which = ios_base::in | ios_base::out);
private:
typedef unsigned __mode_type;
static const __mode_type __allocated = 0x01;
static const __mode_type __constant = 0x02;
static const __mode_type __dynamic = 0x04;
static const __mode_type __frozen = 0x08;
static const streamsize __default_alsize = 4096;
__mode_type __strmode_;
streamsize __alsize_;
void* (*__palloc_)(size_t);
void (*__pfree_)(void*);
void __init(char* __gnext, streamsize __n, char* __pbeg);
};
class istrstream
: public istream
{
public:
explicit istrstream(const char* __s)
: istream(&__sb_), __sb_(__s, 0) {}
explicit istrstream(char* __s)
: istream(&__sb_), __sb_(__s, 0) {}
istrstream(const char* __s, streamsize __n)
: istream(&__sb_), __sb_(__s, __n) {}
istrstream(char* __s, streamsize __n)
: istream(&__sb_), __sb_(__s, __n) {}
#ifdef _LIBCPP_MOVE
istrstream(istrstream&& __rhs)
: istream(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
istream::set_rdbuf(&__sb_);
}
istrstream& operator=(istrstream&& __rhs)
{
istream::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
virtual ~istrstream();
void swap(istrstream& __rhs)
{
istream::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
char *str() {return __sb_.str();}
private:
strstreambuf __sb_;
};
class ostrstream
: public ostream
{
public:
ostrstream()
: ostream(&__sb_) {}
ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
: ostream(&__sb_),
__sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
{}
#ifdef _LIBCPP_MOVE
ostrstream(ostrstream&& __rhs)
: ostream(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
ostream::set_rdbuf(&__sb_);
}
ostrstream& operator=(ostrstream&& __rhs)
{
ostream::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
virtual ~ostrstream();
void swap(ostrstream& __rhs)
{
ostream::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
char* str() {return __sb_.str();}
int pcount() const {return __sb_.pcount();}
private:
strstreambuf __sb_; // exposition only
};
class strstream
: public iostream
{
public:
// Types
typedef char char_type;
typedef char_traits<char>::int_type int_type;
typedef char_traits<char>::pos_type pos_type;
typedef char_traits<char>::off_type off_type;
// constructors/destructor
strstream()
: iostream(&__sb_) {}
strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
: iostream(&__sb_),
__sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0))
{}
#ifdef _LIBCPP_MOVE
strstream(strstream&& __rhs)
: iostream(_STD::move(__rhs)),
__sb_(_STD::move(__rhs.__sb_))
{
iostream::set_rdbuf(&__sb_);
}
strstream& operator=(strstream&& __rhs)
{
iostream::operator=(_STD::move(__rhs));
__sb_ = _STD::move(__rhs.__sb_);
return *this;
}
#endif
virtual ~strstream();
void swap(strstream& __rhs)
{
iostream::swap(__rhs);
__sb_.swap(__rhs.__sb_);
}
// Members:
strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);}
void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);}
int pcount() const {return __sb_.pcount();}
char* str() {return __sb_.str();}
private:
strstreambuf __sb_; // exposition only
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STRSTREAM

607
libcxx/include/system_error Normal file
View File

@ -0,0 +1,607 @@
// -*- C++ -*-
//===---------------------------- system_error ----------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_SYSTEM_ERROR
#define _LIBCPP_SYSTEM_ERROR
/*
system_error synopsis
namespace std
{
class error_category
{
public:
virtual ~error_category();
error_category(const error_category&) = delete;
error_category& operator=(const error_category&) = delete;
virtual const char* name() const = 0;
virtual error_condition default_error_condition(int ev) const;
virtual bool equivalent(int code, const error_condition& condition) const;
virtual bool equivalent(const error_code& code, int condition) const;
virtual string message(int ev) const = 0;
bool operator==(const error_category& rhs) const;
bool operator!=(const error_category& rhs) const;
bool operator<(const error_category& rhs) const;
};
const error_category& generic_category();
const error_category& system_category();
template <class T> struct is_error_code_enum
: public false_type {};
template <class T> struct is_error_condition_enum
: public false_type {};
class error_code
{
public:
// constructors:
error_code();
error_code(int val, const error_category& cat);
template <class ErrorCodeEnum>
error_code(ErrorCodeEnum e);
// modifiers:
void assign(int val, const error_category& cat);
template <class ErrorCodeEnum>
error_code& operator=(ErrorCodeEnum e);
void clear();
// observers:
int value() const;
const error_category& category() const;
error_condition default_error_condition() const;
string message() const;
explicit operator bool() const;
};
// non-member functions:
bool operator<(const error_code& lhs, const error_code& rhs);
template <class charT, class traits>
basic_ostream<charT,traits>&
operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
class error_condition
{
public:
// constructors:
error_condition();
error_condition(int val, const error_category& cat);
template <class ErrorConditionEnum>
error_condition(ErrorConditionEnum e);
// modifiers:
void assign(int val, const error_category& cat);
template <class ErrorConditionEnum>
error_condition& operator=(ErrorConditionEnum e);
void clear();
// observers:
int value() const;
const error_category& category() const;
string message() const;
explicit operator bool() const;
};
bool operator<(const error_condition& lhs, const error_condition& rhs);
class system_error
: public runtime_error
{
public:
system_error(error_code ec, const string& what_arg);
system_error(error_code ec, const char* what_arg);
system_error(error_code ec);
system_error(int ev, const error_category& ecat, const string& what_arg);
system_error(int ev, const error_category& ecat, const char* what_arg);
system_error(int ev, const error_category& ecat);
const error_code& code() const throw();
const char* what() const throw();
};
enum class errc
{
address_family_not_supported, // EAFNOSUPPORT
address_in_use, // EADDRINUSE
address_not_available, // EADDRNOTAVAIL
already_connected, // EISCONN
argument_list_too_long, // E2BIG
argument_out_of_domain, // EDOM
bad_address, // EFAULT
bad_file_descriptor, // EBADF
bad_message, // EBADMSG
broken_pipe, // EPIPE
connection_aborted, // ECONNABORTED
connection_already_in_progress, // EALREADY
connection_refused, // ECONNREFUSED
connection_reset, // ECONNRESET
cross_device_link, // EXDEV
destination_address_required, // EDESTADDRREQ
device_or_resource_busy, // EBUSY
directory_not_empty, // ENOTEMPTY
executable_format_error, // ENOEXEC
file_exists, // EEXIST
file_too_large, // EFBIG
filename_too_long, // ENAMETOOLONG
function_not_supported, // ENOSYS
host_unreachable, // EHOSTUNREACH
identifier_removed, // EIDRM
illegal_byte_sequence, // EILSEQ
inappropriate_io_control_operation, // ENOTTY
interrupted, // EINTR
invalid_argument, // EINVAL
invalid_seek, // ESPIPE
io_error, // EIO
is_a_directory, // EISDIR
message_size, // EMSGSIZE
network_down, // ENETDOWN
network_reset, // ENETRESET
network_unreachable, // ENETUNREACH
no_buffer_space, // ENOBUFS
no_child_process, // ECHILD
no_link, // ENOLINK
no_lock_available, // ENOLCK
no_message_available, // ENODATA
no_message, // ENOMSG
no_protocol_option, // ENOPROTOOPT
no_space_on_device, // ENOSPC
no_stream_resources, // ENOSR
no_such_device_or_address, // ENXIO
no_such_device, // ENODEV
no_such_file_or_directory, // ENOENT
no_such_process, // ESRCH
not_a_directory, // ENOTDIR
not_a_socket, // ENOTSOCK
not_a_stream, // ENOSTR
not_connected, // ENOTCONN
not_enough_memory, // ENOMEM
not_supported, // ENOTSUP
operation_canceled, // ECANCELED
operation_in_progress, // EINPROGRESS
operation_not_permitted, // EPERM
operation_not_supported, // EOPNOTSUPP
operation_would_block, // EWOULDBLOCK
owner_dead, // EOWNERDEAD
permission_denied, // EACCES
protocol_error, // EPROTO
protocol_not_supported, // EPROTONOSUPPORT
read_only_file_system, // EROFS
resource_deadlock_would_occur, // EDEADLK
resource_unavailable_try_again, // EAGAIN
result_out_of_range, // ERANGE
state_not_recoverable, // ENOTRECOVERABLE
stream_timeout, // ETIME
text_file_busy, // ETXTBSY
timed_out, // ETIMEDOUT
too_many_files_open_in_system, // ENFILE
too_many_files_open, // EMFILE
too_many_links, // EMLINK
too_many_symbolic_link_levels, // ELOOP
value_too_large, // EOVERFLOW
wrong_protocol_type // EPROTOTYPE
};
template <> struct is_error_condition_enum<errc>
: true_type { }
error_code make_error_code(errc e);
error_condition make_error_condition(errc e);
// Comparison operators:
bool operator==(const error_code& lhs, const error_code& rhs);
bool operator==(const error_code& lhs, const error_condition& rhs);
bool operator==(const error_condition& lhs, const error_code& rhs);
bool operator==(const error_condition& lhs, const error_condition& rhs);
bool operator!=(const error_code& lhs, const error_code& rhs);
bool operator!=(const error_code& lhs, const error_condition& rhs);
bool operator!=(const error_condition& lhs, const error_code& rhs);
bool operator!=(const error_condition& lhs, const error_condition& rhs);
template <> struct hash<std::error_code>;
} // std
*/
#include <__config>
#include <cerrno>
#include <type_traits>
#include <stdexcept>
#include <__functional_base>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
// is_error_code_enum
template <class _Tp> struct is_error_code_enum
: public false_type {};
// is_error_condition_enum
template <class _Tp> struct is_error_condition_enum
: public false_type {};
//enum class errc
struct errc
{
enum _ {
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
address_not_available = EADDRNOTAVAIL,
already_connected = EISCONN,
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
bad_message = EBADMSG,
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
identifier_removed = EIDRM,
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
no_link = ENOLINK,
no_lock_available = ENOLCK,
no_message_available = ENODATA,
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
no_stream_resources = ENOSR,
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
not_a_stream = ENOSTR,
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
not_supported = ENOTSUP,
operation_canceled = ECANCELED,
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
owner_dead = EOWNERDEAD,
permission_denied = EACCES,
protocol_error = EPROTO,
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
state_not_recoverable = ENOTRECOVERABLE,
stream_timeout = ETIME,
text_file_busy = ETXTBSY,
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_symbolic_link_levels = ELOOP,
value_too_large = EOVERFLOW,
wrong_protocol_type = EPROTOTYPE
};
_ __v_;
errc(_ __v) : __v_(__v) {}
operator int() const {return __v_;}
};
template <> struct is_error_condition_enum<errc>
: true_type { };
template <> struct is_error_condition_enum<errc::_>
: true_type { };
class error_condition;
class error_code;
// class error_category
class __do_message;
class error_category
{
public:
virtual ~error_category();
private:
error_category();
error_category(const error_category&);// = delete;
error_category& operator=(const error_category&);// = delete;
public:
virtual const char* name() const = 0;
virtual error_condition default_error_condition(int __ev) const;
virtual bool equivalent(int __code, const error_condition& __condition) const;
virtual bool equivalent(const error_code& __code, int __condition) const;
virtual string message(int __ev) const = 0;
_LIBCPP_ALWAYS_INLINE
bool operator==(const error_category& __rhs) const {return this == &__rhs;}
_LIBCPP_ALWAYS_INLINE
bool operator!=(const error_category& __rhs) const {return !(*this == __rhs);}
_LIBCPP_ALWAYS_INLINE
bool operator< (const error_category& __rhs) const {return this < &__rhs;}
friend class __do_message;
};
class _LIBCPP_HIDDEN __do_message
: public error_category
{
public:
virtual string message(int ev) const;
};
const error_category& generic_category();
const error_category& system_category();
class error_condition
{
int __val_;
const error_category* __cat_;
public:
_LIBCPP_ALWAYS_INLINE
error_condition() : __val_(0), __cat_(&generic_category()) {}
_LIBCPP_ALWAYS_INLINE
error_condition(int __val, const error_category& __cat)
: __val_(__val), __cat_(&__cat) {}
template <class _E>
_LIBCPP_ALWAYS_INLINE
error_condition(_E __e, typename enable_if<is_error_condition_enum<_E>::value>::type* = 0)
{*this = make_error_condition(__e);}
_LIBCPP_ALWAYS_INLINE
void assign(int __val, const error_category& __cat)
{
__val_ = __val;
__cat_ = &__cat;
}
template <class _E>
_LIBCPP_ALWAYS_INLINE
typename enable_if
<
is_error_condition_enum<_E>::value,
error_condition&
>::type
operator=(_E __e)
{*this = make_error_condition(__e); return *this;}
_LIBCPP_ALWAYS_INLINE
void clear()
{
__val_ = 0;
__cat_ = &generic_category();
}
_LIBCPP_ALWAYS_INLINE
int value() const {return __val_;}
_LIBCPP_ALWAYS_INLINE
const error_category& category() const {return *__cat_;}
string message() const;
_LIBCPP_ALWAYS_INLINE
//explicit
operator bool() const {return __val_ != 0;}
};
inline _LIBCPP_INLINE_VISIBILITY
error_condition
make_error_condition(errc __e)
{
return error_condition(static_cast<int>(__e), generic_category());
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<(const error_condition& __x, const error_condition& __y)
{
return __x.category() < __y.category()
|| __x.category() == __y.category() && __x.value() < __y.value();
}
// error_code
class error_code
{
int __val_;
const error_category* __cat_;
public:
_LIBCPP_ALWAYS_INLINE
error_code() : __val_(0), __cat_(&system_category()) {}
_LIBCPP_ALWAYS_INLINE
error_code(int __val, const error_category& __cat)
: __val_(__val), __cat_(&__cat) {}
template <class _E>
_LIBCPP_ALWAYS_INLINE
error_code(_E __e, typename enable_if<is_error_code_enum<_E>::value>::type* = 0)
{*this = make_error_code(__e);}
_LIBCPP_ALWAYS_INLINE
void assign(int __val, const error_category& __cat)
{
__val_ = __val;
__cat_ = &__cat;
}
template <class _E>
_LIBCPP_ALWAYS_INLINE
typename enable_if
<
is_error_code_enum<_E>::value,
error_code&
>::type
operator=(_E __e)
{*this = make_error_code(__e); return *this;}
_LIBCPP_ALWAYS_INLINE
void clear()
{
__val_ = 0;
__cat_ = &system_category();
}
_LIBCPP_ALWAYS_INLINE
int value() const {return __val_;}
_LIBCPP_ALWAYS_INLINE
const error_category& category() const {return *__cat_;}
_LIBCPP_ALWAYS_INLINE
error_condition default_error_condition() const
{return __cat_->default_error_condition(__val_);}
string message() const;
_LIBCPP_ALWAYS_INLINE
//explicit
operator bool() const {return __val_ != 0;}
};
inline _LIBCPP_INLINE_VISIBILITY
error_code
make_error_code(errc __e)
{
return error_code(static_cast<int>(__e), generic_category());
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<(const error_code& __x, const error_code& __y)
{
return __x.category() < __y.category()
|| __x.category() == __y.category() && __x.value() < __y.value();
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const error_code& __x, const error_code& __y)
{
return __x.category() == __y.category() && __x.value() == __y.value();
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const error_code& __x, const error_condition& __y)
{
return __x.category().equivalent(__x.value(), __y)
|| __y.category().equivalent(__x, __y.value());
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const error_condition& __x, const error_code& __y)
{
return __y == __x;
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const error_condition& __x, const error_condition& __y)
{
return __x.category() == __y.category() && __x.value() == __y.value();
}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const error_code& __x, const error_code& __y) {return !(__x == __y);}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const error_code& __x, const error_condition& __y) {return !(__x == __y);}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const error_condition& __x, const error_code& __y) {return !(__x == __y);}
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const error_condition& __x, const error_condition& __y) {return !(__x == __y);}
template <>
struct hash<error_code>
: public unary_function<error_code, size_t>
{
size_t operator()(const error_code& __ec) const
{
return static_cast<size_t>(__ec.value());
}
};
// system_error
class system_error
: public runtime_error
{
error_code __ec_;
public:
system_error(error_code __ec, const string& __what_arg);
system_error(error_code __ec, const char* __what_arg);
system_error(error_code __ec);
system_error(int __ev, const error_category& __ecat, const string& __what_arg);
system_error(int __ev, const error_category& __ecat, const char* __what_arg);
system_error(int __ev, const error_category& __ecat);
~system_error() throw();
_LIBCPP_ALWAYS_INLINE
const error_code& code() const throw() {return __ec_;}
private:
static string __init(const error_code&, string);
};
void __throw_system_error(int ev, const char* what_arg);
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_SYSTEM_ERROR

27
libcxx/include/tgmath.h Normal file
View File

@ -0,0 +1,27 @@
// -*- C++ -*-
//===-------------------------- tgmath.h ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_TGMATH_H
#define _LIBCPP_TGMATH_H
/*
tgmath.h synopsis
#include <complex.h>
#include <math.h>
*/
#include <complex.h>
#include <math.h>
#pragma GCC system_header
#endif // _LIBCPP_TGMATH_H

322
libcxx/include/thread Normal file
View File

@ -0,0 +1,322 @@
// -*- C++ -*-
//===--------------------------- thread -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_THREAD
#define _LIBCPP_THREAD
/*
thread synopsis
#define __STDCPP_THREADS __cplusplus
namespace std
{
class thread
{
public:
class id;
typedef pthread_t native_handle_type;
thread();
template <class F, class ...Args> explicit thread(F&& f, Args&&... args);
~thread();
thread(const thread&) = delete;
thread(thread&& t);
thread& operator=(const thread&) = delete;
thread& operator=(thread&& t);
void swap(thread& t);
bool joinable() const;
void join();
void detach();
id get_id() const;
native_handle_type native_handle();
static unsigned hardware_concurrency();
};
void swap(thread& x, thread& y);
class thread::id
{
public:
id();
};
bool operator==(thread::id x, thread::id y);
bool operator!=(thread::id x, thread::id y);
bool operator< (thread::id x, thread::id y);
bool operator<=(thread::id x, thread::id y);
bool operator> (thread::id x, thread::id y);
bool operator>=(thread::id x, thread::id y);
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& out, thread::id id);
namespace this_thread
{
thread::id get_id();
void yield();
template <class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);
template <class Rep, class Period>
void sleep_for(const chrono::duration<Rep, Period>& rel_time);
} // this_thread
} // std
*/
#include <__config>
#include <iosfwd>
#include <__functional_base>
#include <type_traits>
#include <cstddef>
#include <functional>
#include <memory>
#include <system_error>
#include <chrono>
#include <__mutex_base>
#include <pthread.h>
#pragma GCC system_header
#define __STDCPP_THREADS __cplusplus
_LIBCPP_BEGIN_NAMESPACE_STD
class thread;
class __thread_id;
namespace this_thread
{
__thread_id get_id();
} // this_thread
class __thread_id
{
pthread_t __id_;
public:
__thread_id() : __id_(0) {}
friend bool operator==(__thread_id __x, __thread_id __y)
{return __x.__id_ == __y.__id_;}
friend bool operator!=(__thread_id __x, __thread_id __y)
{return !(__x == __y);}
friend bool operator< (__thread_id __x, __thread_id __y)
{return __x.__id_ < __y.__id_;}
friend bool operator<=(__thread_id __x, __thread_id __y)
{return !(__y < __x);}
friend bool operator> (__thread_id __x, __thread_id __y)
{return __y < __x ;}
friend bool operator>=(__thread_id __x, __thread_id __y)
{return !(__x < __y);}
template<class _CharT, class _Traits>
friend
basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id)
{return __os << __id.__id_;}
private:
__thread_id(pthread_t __id) : __id_(__id) {}
friend __thread_id this_thread::get_id();
friend class thread;
};
template<class _Tp> struct hash;
template<>
struct hash<__thread_id>
: public unary_function<__thread_id, size_t>
{
size_t operator()(__thread_id __v) const
{
const size_t* const __p = reinterpret_cast<const size_t*>(&__v);
return *__p;
}
};
namespace this_thread
{
inline
__thread_id
get_id()
{
return pthread_self();
}
} // this_thread
class thread
{
pthread_t __t_;
#ifndef _LIBCPP_MOVE
thread(const thread&); // = delete;
thread& operator=(const thread&); // = delete;
#endif
public:
typedef __thread_id id;
typedef pthread_t native_handle_type;
thread() : __t_(0) {}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _F, class ..._Args,
class = typename enable_if
<
!is_same<typename decay<_F>::type, thread>::value
>::type
>
explicit thread(_F&& __f, _Args&&... __args);
#else
template <class _F> explicit thread(_F __f);
#endif
~thread();
#ifdef _LIBCPP_MOVE
thread(const thread&) = delete;
thread(thread&& __t) : __t_(__t.__t_) {__t.__t_ = 0;}
thread& operator=(const thread&) = delete;
thread& operator=(thread&& __t);
#endif
void swap(thread& __t) {_STD::swap(__t_, __t.__t_);}
bool joinable() const {return __t_ != nullptr;}
void join();
void detach();
id get_id() const {return __t_;}
native_handle_type native_handle() {return __t_;}
static unsigned hardware_concurrency();
};
template <class _F>
void*
__thread_proxy(void* __vp)
{
std::unique_ptr<_F> __p(static_cast<_F*>(__vp));
(*__p)();
return nullptr;
}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _F, class ..._Args,
class
>
thread::thread(_F&& __f, _Args&&... __args)
{
typedef decltype(bind(std::forward<_F>(__f), std::forward<_Args>(__args)...)) _G;
std::unique_ptr<_G> __p(new _G(bind(std::forward<_F>(__f),
std::forward<_Args>(__args)...)));
int __ec = pthread_create(&__t_, 0, &__thread_proxy<_G>, __p.get());
if (__ec == 0)
__p.release();
else
__throw_system_error(__ec, "thread constructor failed");
}
#else
template <class _F>
thread::thread(_F __f)
{
std::unique_ptr<_F> __p(new _F(__f));
int __ec = pthread_create(&__t_, 0, &__thread_proxy<_F>, __p.get());
if (__ec == 0)
__p.release();
else
__throw_system_error(__ec, "thread constructor failed");
}
#endif
#ifdef _LIBCPP_MOVE
inline
thread&
thread::operator=(thread&& __t)
{
if (__t_ != nullptr)
terminate();
__t_ = __t.__t_;
__t.__t_ = nullptr;
return *this;
}
#endif
inline
void swap(thread& __x, thread& __y) {__x.swap(__y);}
namespace this_thread
{
void sleep_for(const chrono::nanoseconds& ns);
template <class _Rep, class _Period>
void
sleep_for(const chrono::duration<_Rep, _Period>& __d)
{
using namespace chrono;
nanoseconds __ns = duration_cast<nanoseconds>(__d);
if (__ns < __d)
++__ns;
sleep_for(__ns);
}
template <class _Clock, class _Duration>
void
sleep_until(const chrono::time_point<_Clock, _Duration>& __t)
{
using namespace chrono;
mutex __mut;
condition_variable __cv;
unique_lock<mutex> __lk(__mut);
while (_Clock::now() < __t)
__cv.wait_until(__lk, __t);
}
template <class _Duration>
inline
void
sleep_until(const chrono::time_point<chrono::monotonic_clock, _Duration>& __t)
{
using namespace chrono;
sleep_for(__t - monotonic_clock::now());
}
inline
void yield() {sched_yield();}
} // this_thread
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_THREAD

818
libcxx/include/tuple Normal file
View File

@ -0,0 +1,818 @@
// -*- C++ -*-
//===--------------------------- tuple ------------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_TUPLE
#define _LIBCPP_TUPLE
/*
tuple synopsis
namespace std
{
template <class... T>
class tuple {
public:
constexpr tuple();
explicit tuple(const T&...);
template <class... U>
explicit tuple(U&&...);
tuple(const tuple&) = default;
tuple(tuple&&);
template <class... U>
tuple(const tuple<U...>&);
template <class... U>
tuple(tuple<U...>&&);
template <class U1, class U2>
tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2
template <class U1, class U2>
tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2
// allocator-extended constructors
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const T&...);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, U&&...);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, const tuple&);
template <class Alloc>
tuple(allocator_arg_t, const Alloc& a, tuple&&);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&);
template <class Alloc, class... U>
tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&);
template <class Alloc, class U1, class U2>
tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
template <class Alloc, class U1, class U2>
tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
tuple& operator=(const tuple&);
tuple& operator=(tuple&&);
template <class... U>
tuple& operator=(const tuple<U...>&);
template <class... U>
tuple& operator=(tuple<U...>&&);
template <class U1, class U2>
tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2
template <class U1, class U2>
tuple& operator=(pair<U1, U2>&&); //iffsizeof...(T) == 2
void swap(tuple&);
};
const unspecified ignore;
template <class... T> tuple<V...> make_tuple(T&&...);
template <class... T> tuple<T&...> tie(T&...);
template <class... T, class... U> tuple<T..., U...> tuple_cat(const tuple<T...>&, const tuple<U...>&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(tuple<T...>&&, const tuple<U...>&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(const tuple<T...>&, tuple<U...>&&);
template <class... T, class... U> tuple<T..., U...> tuple_cat(tuple<T...>&&, tuple<U...>&&);
// 20.4.1.4, tuple helper classes:
template <class T> class tuple_size; // undefined
template <class... T> class tuple_size<tuple<T...>>;
template <intsize_t I, class T> class tuple_element; // undefined
template <intsize_t I, class... T> class tuple_element<I, tuple<T...>>;
// 20.4.1.5, element access:
template <intsize_t I, class... T> typename tuple_element<I, tuple<T...>>::type& get(tuple<T...>&);
template <intsize_t I, class... T> typename tuple_element<I, tuple<T...>>::type const& get(const tuple<T...>&);
// 20.4.1.6, relational operators:
template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&);
template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&);
template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&);
template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&);
template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&);
template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&);
template <class... Types, class Alloc>
struct uses_allocator<tuple<Types...>, Alloc>;
template <class... Types>
void swap(tuple<Types...>& x, tuple<Types...>& y);
template <class InputIterator>
InputIterator begin(const std::tuple<InputIterator, InputIterator>& t);
template <class InputIterator>
InputIterator end(const std::tuple<InputIterator, InputIterator>& t);
} // std
*/
#include <__config>
#include <__tuple>
#include <cstddef>
#include <memory>
#include <type_traits>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_HAS_NO_VARIADICS
// tuple_size
template <class ..._Tp>
class tuple_size<tuple<_Tp...>>
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
template <class ..._Tp>
class tuple_size<const tuple<_Tp...>>
: public integral_constant<size_t, sizeof...(_Tp)>
{
};
// tuple_element
template <size_t _Ip, class ..._Tp>
class tuple_element<_Ip, tuple<_Tp...>>
{
public:
typedef typename tuple_element<_Ip, __tuple_types<_Tp...>>::type type;
};
template <size_t _Ip, class ..._Tp>
class tuple_element<_Ip, const tuple<_Tp...>>
{
public:
typedef const typename tuple_element<_Ip, __tuple_types<_Tp...>>::type type;
};
// __tuple_leaf
template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value>
class __tuple_leaf;
template <size_t _Ip, class _Hp, bool _Ep>
inline
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
{
swap(__x.get(), __y.get());
}
template <size_t _Ip, class _Hp, bool>
class __tuple_leaf
{
_Hp value;
__tuple_leaf& operator=(const __tuple_leaf&);
public:
_LIBCPP_INLINE_VISIBILITY __tuple_leaf() : value()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 0>, const _Alloc&)
: value()
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: value(allocator_arg_t(), __a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: value(__a)
{static_assert(!is_reference<_Hp>::value,
"Attempted to default construct a reference element in a tuple");}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(_Tp&& __t)
: value(_STD::forward<_Tp>(__t))
{static_assert(!is_lvalue_reference<_Hp>::value ||
is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: value(_STD::forward<_Tp>(__t))
{static_assert(!is_lvalue_reference<_Hp>::value ||
is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: value(allocator_arg_t(), __a, _STD::forward<_Tp>(__t))
{static_assert(!is_lvalue_reference<_Hp>::value ||
is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: value(_STD::forward<_Tp>(__t), __a)
{static_assert(!is_lvalue_reference<_Hp>::value ||
is_lvalue_reference<_Hp>::value &&
(is_lvalue_reference<_Tp>::value ||
is_same<typename remove_reference<_Tp>::type,
reference_wrapper<
typename remove_reference<_Hp>::type
>
>::value),
"Attempted to construct a reference element in a tuple with an rvalue");}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
: value(__t.get()) {}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf&
operator=(_Tp&& __t)
{
value = _STD::forward<_Tp>(__t);
return *this;
}
_LIBCPP_INLINE_VISIBILITY
int swap(__tuple_leaf& __t)
{
_STD::swap(*this, __t);
return 0;
}
_LIBCPP_INLINE_VISIBILITY _Hp& get() {return value;}
_LIBCPP_INLINE_VISIBILITY const _Hp& get() const {return value;}
};
template <size_t _Ip, class _Hp>
class __tuple_leaf<_Ip, _Hp, true>
: private _Hp
{
__tuple_leaf& operator=(const __tuple_leaf&);
public:
_LIBCPP_INLINE_VISIBILITY __tuple_leaf() {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 1>, const _Alloc& __a)
: _Hp(allocator_arg_t(), __a) {}
template <class _Alloc>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf(integral_constant<int, 2>, const _Alloc& __a)
: _Hp(__a) {}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(_Tp&& __t)
: _Hp(_STD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
: _Hp(_STD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
: _Hp(allocator_arg_t(), __a, _STD::forward<_Tp>(__t)) {}
template <class _Tp, class _Alloc>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
: _Hp(_STD::forward<_Tp>(__t), __a) {}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
explicit __tuple_leaf(const __tuple_leaf<_Ip, _Tp>& __t)
: _Hp(__t.get()) {}
template <class _Tp>
_LIBCPP_INLINE_VISIBILITY
__tuple_leaf&
operator=(_Tp&& __t)
{
_Hp::operator=(_STD::forward<_Tp>(__t));
return *this;
}
_LIBCPP_INLINE_VISIBILITY int swap(__tuple_leaf& __t)
{
_STD::swap(*this, __t);
return 0;
}
_LIBCPP_INLINE_VISIBILITY _Hp& get() {return static_cast<_Hp&>(*this);}
_LIBCPP_INLINE_VISIBILITY const _Hp& get() const {return static_cast<const _Hp&>(*this);}
};
template <class ..._Tp> void __swallow(_Tp&&...) {}
// __tuple_impl
template<class _Indx, class ..._Tp> struct __tuple_impl;
template<size_t ..._Indx, class ..._Tp>
struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
: public __tuple_leaf<_Indx, _Tp>...
{
template <size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
explicit
__tuple_impl(__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
_Up&&... __u) :
__tuple_leaf<_Uf, _Tf>(_STD::forward<_Up>(__u))...,
__tuple_leaf<_Ul, _Tl>()...
{}
template <class _Alloc, size_t ..._Uf, class ..._Tf,
size_t ..._Ul, class ..._Tl, class ..._Up>
explicit
__tuple_impl(allocator_arg_t, const _Alloc& __a,
__tuple_indices<_Uf...>, __tuple_types<_Tf...>,
__tuple_indices<_Ul...>, __tuple_types<_Tl...>,
_Up&&... __u) :
__tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a,
_STD::forward<_Up>(__u))...,
__tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)...
{}
template <class _Tuple,
class = typename enable_if
<
__tuple_convertible<_Tuple, tuple<_Tp...>>::value
>::type
>
__tuple_impl(_Tuple&& __t)
: __tuple_leaf<_Indx, _Tp>(_STD::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(_STD::get<_Indx>(__t)))...
{}
template <class _Alloc, class _Tuple,
class = typename enable_if
<
__tuple_convertible<_Tuple, tuple<_Tp...>>::value
>::type
>
__tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: __tuple_leaf<_Indx, _Tp>(__uses_alloc_ctor<_Tp, _Alloc, typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(), __a,
_STD::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(_STD::get<_Indx>(__t)))...
{}
template <class _Tuple>
typename enable_if
<
__tuple_assignable<_Tuple, tuple<_Tp...>>::value,
__tuple_impl&
>::type
operator=(_Tuple&& __t)
{
__swallow(__tuple_leaf<_Indx, _Tp>::operator=(_STD::forward<typename tuple_element<_Indx,
typename __make_tuple_types<_Tuple>::type>::type>(_STD::get<_Indx>(__t)))...);
return *this;
}
void swap(__tuple_impl& __t)
{
__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
}
};
template <class ..._Tp>
class tuple
{
typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base;
base base_;
template <size_t _Jp, class ..._Up> friend
typename tuple_element<_Jp, tuple<_Up...>>::type& get(tuple<_Up...>&);
template <size_t _Jp, class ..._Up> friend
const typename tuple_element<_Jp, tuple<_Up...>>::type& get(const tuple<_Up...>&);
public:
explicit tuple(const _Tp& ... __t)
: base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <class _Alloc>
tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t)
: base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Tp)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
typename __make_tuple_indices<0>::type(),
typename __make_tuple_types<tuple, 0>::type(),
__t...
) {}
template <class ..._Up,
class = typename enable_if
<
sizeof...(_Up) <= sizeof...(_Tp) &&
__tuple_convertible
<
tuple<_Up...>,
typename __make_tuple_types<tuple,
sizeof...(_Up) < sizeof...(_Tp) ?
sizeof...(_Up) :
sizeof...(_Tp)>::type
>::value
>::type
>
explicit
tuple(_Up&&... __u)
: base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_STD::forward<_Up>(__u)...) {}
template <class _Alloc, class ..._Up,
class = typename enable_if
<
sizeof...(_Up) <= sizeof...(_Tp) &&
__tuple_convertible
<
tuple<_Up...>,
typename __make_tuple_types<tuple,
sizeof...(_Up) < sizeof...(_Tp) ?
sizeof...(_Up) :
sizeof...(_Tp)>::type
>::value
>::type
>
tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
: base_(allocator_arg_t(), __a,
typename __make_tuple_indices<sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(),
_STD::forward<_Up>(__u)...) {}
template <class _Tuple,
class = typename enable_if
<
__tuple_convertible<_Tuple, tuple>::value
>::type
>
tuple(_Tuple&& __t)
: base_(_STD::forward<_Tuple>(__t)) {}
template <class _Alloc, class _Tuple,
class = typename enable_if
<
__tuple_convertible<_Tuple, tuple>::value
>::type
>
tuple(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
: base_(allocator_arg_t(), __a, _STD::forward<_Tuple>(__t)) {}
template <class _Tuple,
class = typename enable_if
<
__tuple_assignable<_Tuple, tuple>::value
>::type
>
tuple&
operator=(_Tuple&& __t)
{
base_.operator=(_STD::forward<_Tuple>(__t));
return *this;
}
void swap(tuple& __t) {base_.swap(__t.base_);}
};
template <>
class tuple<>
{
public:
tuple() {}
template <class _Alloc>
tuple(allocator_arg_t, const _Alloc&) {}
template <class _Alloc>
tuple(allocator_arg_t, const _Alloc&, const tuple&) {}
template <class _U>
tuple(array<_U, 0>) {}
template <class _Alloc, class _U>
tuple(allocator_arg_t, const _Alloc&, array<_U, 0>) {}
void swap(tuple&) {}
};
template <class ..._Tp>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) {__t.swap(__u);}
// get
template <size_t _Ip, class ..._Tp>
inline
typename tuple_element<_Ip, tuple<_Tp...>>::type&
get(tuple<_Tp...>& __t)
{
typedef typename tuple_element<_Ip, tuple<_Tp...>>::type type;
return static_cast<__tuple_leaf<_Ip, type>&>(__t.base_).get();
}
template <size_t _Ip, class ..._Tp>
inline
const typename tuple_element<_Ip, tuple<_Tp...>>::type&
get(const tuple<_Tp...>& __t)
{
typedef typename tuple_element<_Ip, tuple<_Tp...>>::type type;
return static_cast<const __tuple_leaf<_Ip, type>&>(__t.base_).get();
}
// tie
template <class ..._Tp>
inline
tuple<_Tp&...>
tie(_Tp&... __t)
{
return tuple<_Tp&...>(__t...);
}
template <class _Up>
struct __ignore_t
{
__ignore_t() {}
template <class _Tp>
__ignore_t(_Tp&&) {}
template <class _Tp>
const __ignore_t& operator=(_Tp&&) const {return *this;}
};
namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); }
template <class _Tp> class reference_wrapper;
template <class _Tp>
struct ___make_tuple_return
{
typedef _Tp type;
};
template <class _Tp>
struct ___make_tuple_return<reference_wrapper<_Tp>>
{
typedef _Tp& type;
};
template <class _Tp>
struct __make_tuple_return
{
typedef typename ___make_tuple_return<typename decay<_Tp>::type>::type type;
};
template <class... _Tp>
inline
tuple<typename __make_tuple_return<_Tp>::type...>
make_tuple(_Tp&&... __t)
{
return tuple<typename __make_tuple_return<_Tp>::type...>(_STD::forward<_Tp>(__t)...);
}
template <size_t _I>
struct __tuple_equal
{
template <class _Tp, class _Up>
bool operator()(const _Tp& __x, const _Up& __y)
{
return __tuple_equal<_I - 1>()(__x, __y) && get<_I-1>(__x) == get<_I-1>(__y);
}
};
template <>
struct __tuple_equal<0>
{
template <class _Tp, class _Up>
bool operator()(const _Tp&, const _Up&)
{
return true;
}
};
template <class ..._Tp, class ..._Up>
inline
bool
operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_equal<sizeof...(_Tp)>()(__x, __y);
}
template <class ..._Tp, class ..._Up>
inline
bool
operator!=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__x == __y);
}
template <size_t _I>
struct __tuple_less
{
template <class _Tp, class _Up>
bool operator()(const _Tp& __x, const _Up& __y)
{
return __tuple_less<_I-1>()(__x, __y) ||
(!__tuple_less<_I-1>()(__y, __x) && get<_I-1>(__x) < get<_I-1>(__y));
}
};
template <>
struct __tuple_less<0>
{
template <class _Tp, class _Up>
bool operator()(const _Tp&, const _Up&)
{
return false;
}
};
template <class ..._Tp, class ..._Up>
inline
bool
operator<(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_less<sizeof...(_Tp)>()(__x, __y);
}
template <class ..._Tp, class ..._Up>
inline
bool
operator>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __y < __x;
}
template <class ..._Tp, class ..._Up>
inline
bool
operator>=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__x < __y);
}
template <class ..._Tp, class ..._Up>
inline
bool
operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return !(__y < __x);
}
// tuple_cat
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline
tuple<_Tp..., _Up...>
__tuple_cat(const tuple<_Tp...>& __x, __tuple_indices<_I1...>, const tuple<_Up...>& __y, __tuple_indices<_I2...>)
{
return tuple<_Tp..., _Up...>(get<_I1>(__x)..., get<_I2>(__y)...);
}
template <class... _Tp, class... _Up>
inline
tuple<_Tp..., _Up...>
tuple_cat(const tuple<_Tp...>& __x, const tuple<_Up...>& __y)
{
return __tuple_cat(__x, typename __make_tuple_indices<sizeof...(_Tp)>::type(),
__y, typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline
tuple<_Tp..., _Up...>
__tuple_cat(tuple<_Tp...>&& __x, __tuple_indices<_I1...>, const tuple<_Up...>& __y, __tuple_indices<_I2...>)
{
return tuple<_Tp..., _Up...>(_STD::forward<_Tp>(get<_I1>(__x))..., get<_I2>(__y)...);
}
template <class... _Tp, class... _Up>
inline
tuple<_Tp..., _Up...>
tuple_cat(tuple<_Tp...>&& __x, const tuple<_Up...>& __y)
{
return __tuple_cat(_STD::move(__x), typename __make_tuple_indices<sizeof...(_Tp)>::type(),
__y, typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline
tuple<_Tp..., _Up...>
__tuple_cat(const tuple<_Tp...>& __x, __tuple_indices<_I1...>, tuple<_Up...>&& __y, __tuple_indices<_I2...>)
{
return tuple<_Tp..., _Up...>(get<_I1>(__x)..., _STD::forward<_Up>(get<_I2>(__y))...);
}
template <class... _Tp, class... _Up>
inline
tuple<_Tp..., _Up...>
tuple_cat(const tuple<_Tp...>& __x, tuple<_Up...>&& __y)
{
return __tuple_cat(__x, typename __make_tuple_indices<sizeof...(_Tp)>::type(),
_STD::move(__y), typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class... _Tp, size_t ..._I1, class... _Up, size_t ..._I2>
inline
tuple<_Tp..., _Up...>
__tuple_cat(tuple<_Tp...>&& __x, __tuple_indices<_I1...>, tuple<_Up...>&& __y, __tuple_indices<_I2...>)
{
return tuple<_Tp..., _Up...>(_STD::forward<_Tp>(get<_I1>(__x))..., _STD::forward<_Up>(get<_I2>(__y))...);
}
template <class... _Tp, class... _Up>
inline
tuple<_Tp..., _Up...>
tuple_cat(tuple<_Tp...>&& __x, tuple<_Up...>&& __y)
{
return __tuple_cat(_STD::move(__x), typename __make_tuple_indices<sizeof...(_Tp)>::type(),
_STD::move(__y), typename __make_tuple_indices<sizeof...(_Up)>::type());
}
template <class ..._Tp, class _Alloc>
struct uses_allocator<tuple<_Tp...>, _Alloc>
: true_type {};
template <class _InputIterator>
inline
_InputIterator
begin(const std::tuple<_InputIterator, _InputIterator>& __t)
{
return get<0>(__t);
}
template <class _InputIterator>
inline
_InputIterator
end(const std::tuple<_InputIterator, _InputIterator>& __t)
{
return get<1>(__t);
}
template <class _T1, class _T2>
template <class... _Args1, class... _Args2, size_t ..._I1, size_t ..._I2>
inline _LIBCPP_INLINE_VISIBILITY
pair<_T1, _T2>::pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>)
: first(_STD::forward<_Args1>(get<_I1>( __first_args))...),
second(_STD::forward<_Args2>(get<_I2>(__second_args))...)
{
}
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_TUPLE

1525
libcxx/include/type_traits Normal file

File diff suppressed because it is too large Load Diff

84
libcxx/include/typeindex Normal file
View File

@ -0,0 +1,84 @@
// -*- C++ -*-
//===-------------------------- typeindex ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_TYPEINDEX
#define _LIBCPP_TYPEINDEX
/*
typeindex synopsis
namespace std
{
class type_index
{
public:
type_index(const type_info& rhs);
bool operator==(const type_index& rhs) const;
bool operator!=(const type_index& rhs) const;
bool operator< (const type_index& rhs) const;
bool operator<=(const type_index& rhs) const;
bool operator> (const type_index& rhs) const;
bool operator>=(const type_index& rhs) const;
size_t hash_code() const;
const char* name() const;
};
template <>
struct hash<type_index>
: public unary_function<type_index, size_t>
{
size_t operator()(type_index index) const;
};
} // std
*/
#include <__config>
#include <typeinfo>
#include <__functional_base>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
class type_index
{
const type_info* __t_;
public:
type_index(const type_info& __y) : __t_(&__y) {}
bool operator==(const type_index& __y) const {return *__t_ == *__y.__t_;}
bool operator!=(const type_index& __y) const {return *__t_ != *__y.__t_;}
bool operator< (const type_index& __y) const {return __t_->before(*__y.__t_);}
bool operator<=(const type_index& __y) const {return !__y.__t_->before(*__t_);}
bool operator> (const type_index& __y) const {return __y.__t_->before(*__t_);}
bool operator>=(const type_index& __y) const {return !__t_->before(*__y.__t_);}
size_t hash_code() const {return __t_->hash_code();}
const char* name() const {return __t_->name();}
};
template <class _Tp> struct hash;
template <>
struct hash<type_index>
: public unary_function<type_index, size_t>
{
size_t operator()(type_index __index) const {return __index.hash_code();}
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_TYPEINDEX

129
libcxx/include/typeinfo Normal file
View File

@ -0,0 +1,129 @@
// -*- C++ -*-
//===-------------------------- typeinfo ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef __LIBCPP_TYPEINFO
#define __LIBCPP_TYPEINFO
/*
typeinfo synopsis
namespace std {
class type_info
{
public:
virtual ~type_info();
bool operator==(const type_info& rhs) const;
bool operator!=(const type_info& rhs) const;
bool before(const type_info& rhs) const;
size_t hash_code() const throw();
const char* name() const;
type_info(const type_info& rhs) = delete;
type_info& operator=(const type_info& rhs) = delete;
};
class bad_cast
: public exception
{
public:
bad_cast() throw();
bad_cast(const bad_cast&) throw();
bad_cast& operator=(const bad_cast&) throw();
virtual const char* what() const throw();
};
class bad_typeid
: public exception
{
public:
bad_typeid() throw();
bad_typeid(const bad_typeid&) throw();
bad_typeid& operator=(const bad_typeid&) throw();
virtual const char* what() const throw();
};
} // std
*/
#include <__config>
#include <exception>
#include <cstddef>
#pragma GCC system_header
#pragma GCC visibility push(default)
namespace __cxxabiv1
{
class __class_type_info;
}
namespace std // purposefully not using versioning namespace
{
class type_info
{
type_info& operator=(const type_info&);
type_info(const type_info&);
protected:
const char* __type_name;
explicit type_info(const char* __n)
: __type_name(__n) {}
public:
virtual ~type_info();
const char* name() const {return __type_name;}
bool before(const type_info& __arg) const
{return __type_name < __arg.__type_name;}
size_t hash_code() const throw()
{return *reinterpret_cast<const size_t*>(&__type_name);}
bool operator==(const type_info& __arg) const
{return __type_name == __arg.__type_name;}
bool operator!=(const type_info& __arg) const
{return !operator==(__arg);}
virtual bool __is_pointer_p() const;
virtual bool __is_function_p() const;
virtual bool __do_catch(const type_info*, void**, unsigned) const;
virtual bool __do_upcast(const __cxxabiv1::__class_type_info*, void**) const;
};
class bad_cast
: public exception
{
public:
bad_cast() throw() {}
virtual ~bad_cast() throw();
virtual const char* what() const throw();
};
class bad_typeid
: public exception
{
public:
bad_typeid () throw() { }
virtual ~bad_typeid() throw();
virtual const char* what() const throw();
};
} // std
#pragma GCC visibility pop
#endif // __LIBCPP_TYPEINFO

1511
libcxx/include/unordered_map Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,956 @@
// -*- C++ -*-
//===-------------------------- unordered_set -----------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_UNORDERED_SET
#define _LIBCPP_UNORDERED_SET
/*
unordered_set synopsis
#include <initializer_list>
namespace std
{
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
class Alloc = allocator<Value>>
class unordered_set
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator;
explicit unordered_set(size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
unordered_set(InputIterator f, InputIterator l,
size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit unordered_set(const allocator_type&);
unordered_set(const unordered_set&);
unordered_set(const unordered_set&, const Allocator&);
unordered_set(unordered_set&&);
unordered_set(unordered_set&&, const Allocator&);
unordered_set(initializer_list<value_type>, size_type n = 0,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
~unordered_set();
unordered_set& operator=(const unordered_set&);
unordered_set& operator=(unordered_set&&);
unordered_set& operator=(initializer_list<value_type>);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
template <class... Args>
pair<iterator, bool> emplace(Args&&... args);
template <class... Args>
iterator emplace_hint(const_iterator position, Args&&... args);
pair<iterator, bool> insert(const value_type& obj);
pair<iterator, bool> insert(value_type&& obj);
iterator insert(const_iterator hint, const value_type& obj);
iterator insert(const_iterator hint, value_type&& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear();
void swap(unordered_set&);
hasher hash_function() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
local_iterator end(size_type n);
const_local_iterator begin(size_type n) const;
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
float load_factor() const;
float max_load_factor() const;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};
template <class Value, class Hash, class Pred, class Alloc>
void swap(unordered_set<Value, Hash, Pred, Alloc>& x,
unordered_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator==(const unordered_set<Value, Hash, Pred, Alloc>& x,
const unordered_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator!=(const unordered_set<Value, Hash, Pred, Alloc>& x,
const unordered_set<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
class Alloc = allocator<Value>>
class unordered_multiset
{
public:
// types
typedef Value key_type;
typedef key_type value_type;
typedef Hash hasher;
typedef Pred key_equal;
typedef Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename allocator_traits<allocator_type>::pointer pointer;
typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
typedef typename allocator_traits<allocator_type>::size_type size_type;
typedef typename allocator_traits<allocator_type>::difference_type difference_type;
typedef /unspecified/ iterator;
typedef /unspecified/ const_iterator;
typedef /unspecified/ local_iterator;
typedef /unspecified/ const_local_iterator;
explicit unordered_multiset(size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
template <class InputIterator>
unordered_multiset(InputIterator f, InputIterator l,
size_type n = 0, const hasher& hf = hasher(),
const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
explicit unordered_multiset(const allocator_type&);
unordered_multiset(const unordered_multiset&);
unordered_multiset(const unordered_multiset&, const Allocator&);
unordered_multiset(unordered_multiset&&);
unordered_multiset(unordered_multiset&&, const Allocator&);
unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
const hasher& hf = hasher(), const key_equal& eql = key_equal(),
const allocator_type& a = allocator_type());
~unordered_multiset();
unordered_multiset& operator=(const unordered_multiset&);
unordered_multiset& operator=(unordered_multiset&&);
unordered_multiset& operator=(initializer_list<value_type>);
allocator_type get_allocator() const;
bool empty() const;
size_type size() const;
size_type max_size() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
template <class... Args>
iterator emplace(Args&&... args);
template <class... Args>
iterator emplace_hint(const_iterator position, Args&&... args);
iterator insert(const value_type& obj);
iterator insert(value_type&& obj);
iterator insert(const_iterator hint, const value_type& obj);
iterator insert(const_iterator hint, value_type&& obj);
template <class InputIterator>
void insert(InputIterator first, InputIterator last);
void insert(initializer_list<value_type>);
iterator erase(const_iterator position);
size_type erase(const key_type& k);
iterator erase(const_iterator first, const_iterator last);
void clear();
void swap(unordered_multiset&);
hasher hash_function() const;
key_equal key_eq() const;
iterator find(const key_type& k);
const_iterator find(const key_type& k) const;
size_type count(const key_type& k) const;
pair<iterator, iterator> equal_range(const key_type& k);
pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
size_type bucket_count() const;
size_type max_bucket_count() const;
size_type bucket_size(size_type n) const;
size_type bucket(const key_type& k) const;
local_iterator begin(size_type n);
local_iterator end(size_type n);
const_local_iterator begin(size_type n) const;
const_local_iterator end(size_type n) const;
const_local_iterator cbegin(size_type n) const;
const_local_iterator cend(size_type n) const;
float load_factor() const;
float max_load_factor() const;
void max_load_factor(float z);
void rehash(size_type n);
void reserve(size_type n);
};
template <class Value, class Hash, class Pred, class Alloc>
void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x,
unordered_multiset<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator==(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
const unordered_multiset<Value, Hash, Pred, Alloc>& y);
template <class Value, class Hash, class Pred, class Alloc>
bool
operator!=(const unordered_multiset<Value, Hash, Pred, Alloc>& x,
const unordered_multiset<Value, Hash, Pred, Alloc>& y);
} // std
*/
#include <__config>
#include <__hash_table>
#include <functional>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class unordered_set
{
public:
// types
typedef _Value key_type;
typedef key_type value_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
typedef typename __table::pointer pointer;
typedef typename __table::const_pointer const_pointer;
typedef typename __table::size_type size_type;
typedef typename __table::difference_type difference_type;
typedef typename __table::const_iterator iterator;
typedef typename __table::const_iterator const_iterator;
typedef typename __table::const_local_iterator local_iterator;
typedef typename __table::const_local_iterator const_local_iterator;
unordered_set() {} // = default;
explicit unordered_set(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
template <class _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
explicit unordered_set(const allocator_type& __a);
unordered_set(const unordered_set& __u);
unordered_set(const unordered_set& __u, const allocator_type& __a);
#ifdef _LIBCPP_MOVE
unordered_set(unordered_set&& __u);
unordered_set(unordered_set&& __u, const allocator_type& __a);
#endif
unordered_set(initializer_list<value_type> __il);
unordered_set(initializer_list<value_type> __il, size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
unordered_set(initializer_list<value_type> __il, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
// ~unordered_set() = default;
// unordered_set& operator=(const unordered_set& __u) = default;
#ifdef _LIBCPP_MOVE
unordered_set& operator=(unordered_set&& __u);
#endif
unordered_set& operator=(initializer_list<value_type> __il);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
const_iterator cbegin() const {return __table_.begin();}
const_iterator cend() const {return __table_.end();}
#ifdef _LIBCPP_MOVE
template <class... _Args>
pair<iterator, bool> emplace(_Args&&... __args)
{return __table_.__emplace_unique(_STD::forward<_Args>(__args)...);}
template <class... _Args>
iterator emplace_hint(const_iterator, _Args&&... __args)
{return __table_.__emplace_unique(_STD::forward<_Args>(__args)...).first;}
#endif
pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
#ifdef _LIBCPP_MOVE
pair<iterator, bool> insert(value_type&& __x)
{return __table_.__insert_unique(_STD::move(__x));}
#endif
iterator insert(const_iterator, const value_type& __x)
{return insert(__x).first;}
#ifdef _LIBCPP_MOVE
iterator insert(const_iterator, value_type&& __x)
{return insert(_STD::move(__x)).first;}
#endif
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
iterator erase(const_iterator __p) {return __table_.erase(__p);}
size_type erase(const key_type& __k) {return __table_.__erase_unique(__k);}
iterator erase(const_iterator __first, const_iterator __last)
{return __table_.erase(__first, __last);}
void clear() {__table_.clear();}
void swap(unordered_set& __u) {__table_.swap(__u.__table_);}
hasher hash_function() const {return __table_.hash_function();}
key_equal key_eq() const {return __table_.key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
local_iterator begin(size_type __n) {return __table_.begin(__n);}
local_iterator end(size_type __n) {return __table_.end(__n);}
const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
float load_factor() const {return __table_.load_factor();}
float max_load_factor() const {return __table_.max_load_factor();}
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
void rehash(size_type __n) {__table_.rehash(__n);}
void reserve(size_type __n) {__table_.reserve(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
_InputIterator __first, _InputIterator __last)
{
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const allocator_type& __a)
: __table_(__a)
{
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const unordered_set& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
const unordered_set& __u, const allocator_type& __a)
: __table_(__u.__table_, __a)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
#ifdef _LIBCPP_MOVE
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
unordered_set&& __u)
: __table_(_STD::move(__u.__table_))
{
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
unordered_set&& __u, const allocator_type& __a)
: __table_(_STD::move(__u.__table_), __a)
{
if (__a != __u.get_allocator())
{
iterator __i = __u.begin();
while (__u.size() != 0)
__table_.__insert_unique(_STD::move(__u.__table_.remove(__i++)->__value_));
}
}
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
initializer_list<value_type> __il)
{
insert(__il.begin(), __il.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__il.begin(), __il.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__il.begin(), __il.end());
}
#ifdef _LIBCPP_MOVE
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_set<_Value, _Hash, _Pred, _Alloc>&
unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(unordered_set&& __u)
{
__table_ = _STD::move(__u.__table_);
return *this;
}
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_set<_Value, _Hash, _Pred, _Alloc>&
unordered_set<_Value, _Hash, _Pred, _Alloc>::operator=(
initializer_list<value_type> __il)
{
__table_.__assign_unique(__il.begin(), __il.end());
return *this;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_unique(*__first);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
void
swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
__i != __ex; ++__i)
{
const_iterator __j = __y.find(*__i);
if (__j == __ey || !(*__i == *__j))
return false;
}
return true;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
class _Alloc = allocator<_Value> >
class unordered_multiset
{
public:
// types
typedef _Value key_type;
typedef key_type value_type;
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
public:
typedef typename __table::pointer pointer;
typedef typename __table::const_pointer const_pointer;
typedef typename __table::size_type size_type;
typedef typename __table::difference_type difference_type;
typedef typename __table::const_iterator iterator;
typedef typename __table::const_iterator const_iterator;
typedef typename __table::const_local_iterator local_iterator;
typedef typename __table::const_local_iterator const_local_iterator;
unordered_multiset() {} // = default
explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
unordered_multiset(size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a);
template <class _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last);
template <class _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n, const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
template <class _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n , const hasher& __hf,
const key_equal& __eql, const allocator_type& __a);
explicit unordered_multiset(const allocator_type& __a);
unordered_multiset(const unordered_multiset& __u);
unordered_multiset(const unordered_multiset& __u, const allocator_type& __a);
#ifdef _LIBCPP_MOVE
unordered_multiset(unordered_multiset&& __u);
unordered_multiset(unordered_multiset&& __u, const allocator_type& __a);
#endif
unordered_multiset(initializer_list<value_type> __il);
unordered_multiset(initializer_list<value_type> __il, size_type __n,
const hasher& __hf = hasher(),
const key_equal& __eql = key_equal());
unordered_multiset(initializer_list<value_type> __il, size_type __n,
const hasher& __hf, const key_equal& __eql,
const allocator_type& __a);
// ~unordered_multiset() = default;
// unordered_multiset& operator=(const unordered_multiset& __u) = default;
#ifdef _LIBCPP_MOVE
unordered_multiset& operator=(unordered_multiset&& __u);
#endif
unordered_multiset& operator=(initializer_list<value_type> __il);
allocator_type get_allocator() const
{return allocator_type(__table_.__node_alloc());}
bool empty() const {return __table_.size() == 0;}
size_type size() const {return __table_.size();}
size_type max_size() const {return __table_.max_size();}
iterator begin() {return __table_.begin();}
iterator end() {return __table_.end();}
const_iterator begin() const {return __table_.begin();}
const_iterator end() const {return __table_.end();}
const_iterator cbegin() const {return __table_.begin();}
const_iterator cend() const {return __table_.end();}
#ifdef _LIBCPP_MOVE
template <class... _Args>
iterator emplace(_Args&&... __args)
{return __table_.__emplace_multi(_STD::forward<_Args>(__args)...);}
template <class... _Args>
iterator emplace_hint(const_iterator __p, _Args&&... __args)
{return __table_.__emplace_hint_multi(__p, _STD::forward<_Args>(__args)...);}
#endif
iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);}
#ifdef _LIBCPP_MOVE
iterator insert(value_type&& __x) {return __table_.__insert_multi(_STD::move(__x));}
#endif
iterator insert(const_iterator __p, const value_type& __x)
{return __table_.__insert_multi(__p, __x);}
#ifdef _LIBCPP_MOVE
iterator insert(const_iterator __p, value_type&& __x)
{return __table_.__insert_multi(__p, _STD::move(__x));}
#endif
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last);
void insert(initializer_list<value_type> __il)
{insert(__il.begin(), __il.end());}
iterator erase(const_iterator __p) {return __table_.erase(__p);}
size_type erase(const key_type& __k) {return __table_.__erase_multi(__k);}
iterator erase(const_iterator __first, const_iterator __last)
{return __table_.erase(__first, __last);}
void clear() {__table_.clear();}
void swap(unordered_multiset& __u) {__table_.swap(__u.__table_);}
hasher hash_function() const {return __table_.hash_function();}
key_equal key_eq() const {return __table_.key_eq();}
iterator find(const key_type& __k) {return __table_.find(__k);}
const_iterator find(const key_type& __k) const {return __table_.find(__k);}
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
size_type bucket_count() const {return __table_.bucket_count();}
size_type max_bucket_count() const {return __table_.max_bucket_count();}
size_type bucket_size(size_type __n) const {return __table_.bucket_size(__n);}
size_type bucket(const key_type& __k) const {return __table_.bucket(__k);}
local_iterator begin(size_type __n) {return __table_.begin(__n);}
local_iterator end(size_type __n) {return __table_.end(__n);}
const_local_iterator begin(size_type __n) const {return __table_.cbegin(__n);}
const_local_iterator end(size_type __n) const {return __table_.cend(__n);}
const_local_iterator cbegin(size_type __n) const {return __table_.cbegin(__n);}
const_local_iterator cend(size_type __n) const {return __table_.cend(__n);}
float load_factor() const {return __table_.load_factor();}
float max_load_factor() const {return __table_.max_load_factor();}
void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);}
void rehash(size_type __n) {__table_.rehash(__n);}
void reserve(size_type __n) {__table_.reserve(__n);}
};
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
size_type __n, const hasher& __hf, const key_equal& __eql,
const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
_InputIterator __first, _InputIterator __last)
{
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
_InputIterator __first, _InputIterator __last, size_type __n,
const hasher& __hf, const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__first, __last);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const allocator_type& __a)
: __table_(__a)
{
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const unordered_multiset& __u)
: __table_(__u.__table_)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
const unordered_multiset& __u, const allocator_type& __a)
: __table_(__u.__table_, __a)
{
__table_.rehash(__u.bucket_count());
insert(__u.begin(), __u.end());
}
#ifdef _LIBCPP_MOVE
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
unordered_multiset&& __u)
: __table_(_STD::move(__u.__table_))
{
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
unordered_multiset&& __u, const allocator_type& __a)
: __table_(_STD::move(__u.__table_), __a)
{
if (__a != __u.get_allocator())
{
iterator __i = __u.begin();
while (__u.size() != 0)
__table_.__insert_multi(_STD::move(__u.__table_.remove(__i++)->__value_));
}
}
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
initializer_list<value_type> __il)
{
insert(__il.begin(), __il.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql)
: __table_(__hf, __eql)
{
__table_.rehash(__n);
insert(__il.begin(), __il.end());
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
initializer_list<value_type> __il, size_type __n, const hasher& __hf,
const key_equal& __eql, const allocator_type& __a)
: __table_(__hf, __eql, __a)
{
__table_.rehash(__n);
insert(__il.begin(), __il.end());
}
#ifdef _LIBCPP_MOVE
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
unordered_multiset&& __u)
{
__table_ = _STD::move(__u.__table_);
return *this;
}
#endif
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
unordered_multiset<_Value, _Hash, _Pred, _Alloc>&
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::operator=(
initializer_list<value_type> __il)
{
__table_.__assign_multi(__il.begin(), __il.end());
return *this;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
template <class _InputIterator>
inline
void
unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
_InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_multi(*__first);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
void
swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
__x.swap(__y);
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
bool
operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
if (__x.size() != __y.size())
return false;
typedef typename unordered_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
typedef pair<const_iterator, const_iterator> _EqRng;
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
{
_EqRng __xeq = __x.equal_range(*__i);
_EqRng __yeq = __y.equal_range(*__i);
if (_STD::distance(__xeq.first, __xeq.second) !=
_STD::distance(__yeq.first, __yeq.second) ||
!_STD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
return false;
__i = __xeq.second;
}
return true;
}
template <class _Value, class _Hash, class _Pred, class _Alloc>
inline
bool
operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
{
return !(__x == __y);
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_UNORDERED_SET

481
libcxx/include/utility Normal file
View File

@ -0,0 +1,481 @@
// -*- C++ -*-
//===-------------------------- utility -----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_UTILITY
#define _LIBCPP_UTILITY
/*
utility synopsis
namespace std
{
template <class T>
void
swap(T& a, T& b);
namespace rel_ops
{
template<class T> bool operator!=(const T&, const T&);
template<class T> bool operator> (const T&, const T&);
template<class T> bool operator<=(const T&, const T&);
template<class T> bool operator>=(const T&, const T&);
}
template<class T> void swap(T& a, T& b);
template <class T, size_t N> void swap(T (&a)[N], T (&b)[N]);
template <class T, class U> T&& forward(U&&);
template <class T> typename remove_reference<T>::type&& move(T&&);
template <class T>
typename conditional
<
!has_nothrow_move_constructor<T>::value && has_copy_constructor<T>::value,
const T&,
T&&
>::type
move_if_noexcept(T& x);
template <class T> typename add_rvalue_reference<T>::type declval() noexcept;
template <class T1, class T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair(const pair&) = default;
constexpr pair();
pair(const T1& x, const T2& y);
template <class U, class V> pair(U&& x, V&& y);
template <class U, class V> pair(const pair<U, V>& p);
template <class U, class V> pair(pair<U, V>&& p);
template <class... Args1, class... Args2>
pair(piecewise_construct_t, tuple<Args1...> first_args,
tuple<Args2...> second_args);
template <class U, class V> pair& operator=(const pair<U, V>& p);
pair& operator=(pair&& p);
template <class U, class V> pair& operator=(pair<U, V>&& p);
void swap(pair& p);
};
template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&);
template <class T1, class T2> void swap(pair<T1, T2>& x, pair<T1, T2>& y);
struct piecewise_construct_t { };
constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
template <class T> class tuple_size;
template <size_t I, class T> class tuple_element;
template <class T1, class T2> struct tuple_size<std::pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<0, std::pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<1, std::pair<T1, T2> >;
template<size_t I, class T1, class T2>
typename tuple_element<I, std::pair<T1, T2> >::type&
get(std::pair<T1, T2>&);
template<size_t I, class T1, class T2>
const typename const tuple_element<I, std::pair<T1, T2> >::type&
get(const std::pair<T1, T2>&);
template <class InputIterator>
InputIterator begin(const std::pair<InputIterator, InputIterator>& p);
template <class InputIterator>
InputIterator end(const std::pair<InputIterator, InputIterator>& p);
} // std
*/
#include <__config>
#include <__tuple>
#include <type_traits>
#pragma GCC system_header
_LIBCPP_BEGIN_NAMESPACE_STD
namespace rel_ops
{
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const _Tp& __x, const _Tp& __y)
{
return !(__x == __y);
}
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const _Tp& __x, const _Tp& __y)
{
return __y < __x;
}
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const _Tp& __x, const _Tp& __y)
{
return !(__y < __x);
}
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const _Tp& __x, const _Tp& __y)
{
return !(__x < __y);
}
} // rel_ops
// swap_ranges
template <class _ForwardIterator1, class _ForwardIterator2>
inline _LIBCPP_INLINE_VISIBILITY
_ForwardIterator2
swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
{
for(; __first1 != __last1; ++__first1, ++__first2)
swap(*__first1, *__first2);
return __first2;
}
template<class _Tp, size_t _N>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(_Tp (&__a)[_N], _Tp (&__b)[_N])
{
_STD::swap_ranges(__a, __a + _N, __b);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
#ifdef _LIBCPP_MOVE
typename conditional
<
!has_nothrow_move_constructor<_Tp>::value && has_copy_constructor<_Tp>::value,
const _Tp&,
_Tp&&
>::type
#else
const _Tp&
#endif
move_if_noexcept(_Tp& __x)
{
return _STD::move(__x);
}
struct piecewise_construct_t { };
//constexpr
extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
template <class _T1, class _T2> struct pair;
template <class _T1, class _T2> void swap(pair<_T1, _T2>&, pair<_T1, _T2>&);
template <class _T1, class _T2>
struct pair
{
typedef _T1 first_type;
typedef _T2 second_type;
_T1 first;
_T2 second;
_LIBCPP_INLINE_VISIBILITY pair() : first(), second() {}
_LIBCPP_INLINE_VISIBILITY pair(const _T1& __x, const _T2& __y)
: first(__x), second(__y) {}
#ifdef _LIBCPP_MOVE
template <class _U1, class _U2,
class = typename enable_if<is_convertible<_U1, first_type >::value &&
is_convertible<_U2, second_type>::value>::type>
_LIBCPP_INLINE_VISIBILITY
pair(_U1&& __u1, _U2&& __u2)
: first(_STD::forward<_U1>(__u1)),
second(_STD::forward<_U2>(__u2))
{}
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
pair(_Tuple&& __p)
: first(_STD::forward<typename tuple_element<0,
typename __make_tuple_types<_Tuple>::type>::type>(get<0>(__p))),
second(_STD::forward<typename tuple_element<1,
typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))
{}
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args,
tuple<_Args2...> __second_args)
: pair(__pc, __first_args, __second_args,
typename __make_tuple_indices<sizeof...(_Args1)>::type(),
typename __make_tuple_indices<sizeof...(_Args2) >::type())
{}
#endif
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
pair&
operator=(_Tuple&& __p)
{
typedef typename __make_tuple_types<_Tuple>::type _TupleRef;
typedef typename tuple_element<0, _TupleRef>::type _U0;
typedef typename tuple_element<1, _TupleRef>::type _U1;
first = _STD::forward<_U0>(_STD::get<0>(__p));
second = _STD::forward<_U1>(_STD::get<1>(__p));
return *this;
}
#else
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) {}
#endif
void _LIBCPP_INLINE_VISIBILITY swap(pair& __p) {_STD::swap(*this, __p);}
private:
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
pair(piecewise_construct_t,
tuple<_Args1...>& __first_args, tuple<_Args2...>& __second_args,
__tuple_indices<_I1...>, __tuple_indices<_I2...>);
#endif
};
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __x.first == __y.first && __x.second == __y.second;
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__x == __y);
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator< (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator> (const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return __y < __x;
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__x < __y);
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)
{
return !(__y < __x);
}
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
void
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
{
swap(__x.first, __y.first);
swap(__x.second, __y.second);
}
#ifdef _LIBCPP_MOVE
template <class _Tp> class reference_wrapper;
template <class _Tp>
struct ___make_pair_return
{
typedef _Tp type;
};
template <class _Tp>
struct ___make_pair_return<reference_wrapper<_Tp>>
{
typedef _Tp& type;
};
template <class _Tp>
struct __make_pair_return
{
typedef typename ___make_pair_return<typename decay<_Tp>::type>::type type;
};
template <class _T1, class _T2>
inline
pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
make_pair(_T1&& __t1, _T2&& __t2)
{
return pair<typename __make_pair_return<_T1>::type, typename __make_pair_return<_T2>::type>
(_STD::forward<_T1>(__t1), _STD::forward<_T2>(__t2));
}
#else
template <class _T1, class _T2>
inline _LIBCPP_INLINE_VISIBILITY
pair<_T1,_T2>
make_pair(_T1 __x, _T2 __y)
{
return pair<_T1, _T2>(__x, __y);
}
#endif
#ifndef _LIBCPP_HAS_NO_VARIADICS
template <class _T1, class _T2>
class tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
class tuple_size<const pair<_T1, _T2> > : public integral_constant<size_t, 2> {};
template <class _T1, class _T2>
class tuple_element<0, pair<_T1, _T2> >
{
public:
typedef _T1 type;
};
template <class _T1, class _T2>
class tuple_element<1, pair<_T1, _T2> >
{
public:
typedef _T2 type;
};
template <class _T1, class _T2>
class tuple_element<0, const pair<_T1, _T2> >
{
public:
typedef const _T1 type;
};
template <class _T1, class _T2>
class tuple_element<1, const pair<_T1, _T2> >
{
public:
typedef const _T2 type;
};
template <size_t _Ip> struct __get_pair;
template <>
struct __get_pair<0>
{
template <class _T1, class _T2>
static
_LIBCPP_INLINE_VISIBILITY
_T1&
get(pair<_T1, _T2>& __p) {return __p.first;}
template <class _T1, class _T2>
static
_LIBCPP_INLINE_VISIBILITY
const _T1&
get(const pair<_T1, _T2>& __p) {return __p.first;}
};
template <>
struct __get_pair<1>
{
template <class _T1, class _T2>
static
_LIBCPP_INLINE_VISIBILITY
_T2&
get(pair<_T1, _T2>& __p) {return __p.second;}
template <class _T1, class _T2>
static
_LIBCPP_INLINE_VISIBILITY
const _T2&
get(const pair<_T1, _T2>& __p) {return __p.second;}
};
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY inline
typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(pair<_T1, _T2>& __p)
{
return __get_pair<_Ip>::get(__p);
}
template <size_t _Ip, class _T1, class _T2>
_LIBCPP_INLINE_VISIBILITY inline
const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
get(const pair<_T1, _T2>& __p)
{
return __get_pair<_Ip>::get(__p);
}
#endif
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY inline
_InputIterator
begin(const pair<_InputIterator, _InputIterator>& __p)
{
return __p.first;
}
template <class _InputIterator>
_LIBCPP_INLINE_VISIBILITY inline
_InputIterator
end(const pair<_InputIterator, _InputIterator>& __p)
{
return __p.second;
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_UTILITY

4738
libcxx/include/valarray Normal file

File diff suppressed because it is too large Load Diff

2783
libcxx/include/vector Normal file

File diff suppressed because it is too large Load Diff

42
libcxx/lib/buildit Executable file
View File

@ -0,0 +1,42 @@
if [ `basename $(pwd)` != "lib" ]
then
echo "current directory must be lib"
exit 1
fi
if [ -z $CC ]
then
CC=g++
fi
if [ -z $RC_BUILDIT ]
then
RC_CFLAGS="-arch i386 -arch ppc -arch x86_64"
fi
if [ -z $RC_BUILDIT ]
then
rm libc++.1.dylib
fi
set -x
for FILE in $(ls ../src/*.cpp); do
$CC -c -g -Os $RC_CFLAGS -nostdinc++ -I../include $FILE
done
$CC -dynamiclib -nodefaultlibs $RC_CFLAGS -current_version 1 \
-compatibility_version 1 \
-o libc++.1.dylib *.o \
-install_name /usr/lib/libc++.dylib \
-Wl,-reexport_library,/usr/lib/libc++abi.dylib \
/usr/lib/libSystem.B.dylib
#libtool -static -o libc++.a *.o
set +x
if [ -z $RC_BUILDIT ]
then
rm *.o
fi

48
libcxx/src/algorithm.cpp Normal file
View File

@ -0,0 +1,48 @@
//===----------------------- algorithm.cpp --------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "algorithm"
_LIBCPP_BEGIN_NAMESPACE_STD
template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
_LIBCPP_END_NAMESPACE_STD

31
libcxx/src/bind.cpp Normal file
View File

@ -0,0 +1,31 @@
//===-------------------------- bind.cpp ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "functional"
_LIBCPP_BEGIN_NAMESPACE_STD
namespace placeholders
{
__ph<1> _1;
__ph<2> _2;
__ph<3> _3;
__ph<4> _4;
__ph<5> _5;
__ph<6> _6;
__ph<7> _7;
__ph<8> _8;
__ph<9> _9;
__ph<10> _10;
} // placeholders
_LIBCPP_END_NAMESPACE_STD

101
libcxx/src/chrono.cpp Normal file
View File

@ -0,0 +1,101 @@
//===------------------------- chrono.cpp ---------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "chrono"
#include <sys/time.h> //for gettimeofday and timeval
#include <mach/mach_time.h> // mach_absolute_time, mach_timebase_info_data_t
_LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono
{
// system_clock
system_clock::time_point
system_clock::now()
{
timeval tv;
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
}
time_t
system_clock::to_time_t(const time_point& t)
{
return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
}
system_clock::time_point
system_clock::from_time_t(time_t t)
{
return system_clock::time_point(seconds(t));
}
// monotonic_clock
// mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
// nanoseconds since the computer booted up. MachInfo.numer and MachInfo.denom
// are run time constants supplied by the OS. This clock has no relationship
// to the Gregorian calendar. It's main use is as a high resolution timer.
// MachInfo.numer / MachInfo.denom is often 1 on the latest equipment. Specialize
// for that case as an optimization.
#pragma GCC visibility push(hidden)
static
monotonic_clock::rep
monotonic_simplified()
{
return mach_absolute_time();
}
static
double
compute_monotonic_factor()
{
mach_timebase_info_data_t MachInfo;
mach_timebase_info(&MachInfo);
return static_cast<double>(MachInfo.numer) / MachInfo.denom;
}
static
monotonic_clock::rep
monotonic_full()
{
static const double factor = compute_monotonic_factor();
return static_cast<monotonic_clock::rep>(mach_absolute_time() * factor);
}
typedef monotonic_clock::rep (*FP)();
static
FP
init_monotonic_clock()
{
mach_timebase_info_data_t MachInfo;
mach_timebase_info(&MachInfo);
if (MachInfo.numer == MachInfo.denom)
return &monotonic_simplified;
return &monotonic_full;
}
#pragma GCC visiblity pop
monotonic_clock::time_point
monotonic_clock::now()
{
static FP fp = init_monotonic_clock();
return time_point(duration(fp()));
}
}
_LIBCPP_END_NAMESPACE_STD

View File

@ -0,0 +1,64 @@
//===-------------------- condition_variable.cpp --------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "condition_variable"
#include "thread"
#include "system_error"
#include "cassert"
_LIBCPP_BEGIN_NAMESPACE_STD
condition_variable::~condition_variable()
{
int e = pthread_cond_destroy(&__cv_);
// assert(e == 0);
}
void
condition_variable::notify_one()
{
pthread_cond_signal(&__cv_);
}
void
condition_variable::notify_all()
{
pthread_cond_broadcast(&__cv_);
}
void
condition_variable::wait(unique_lock<mutex>& lk)
{
if (!lk.owns_lock())
__throw_system_error(EPERM,
"condition_variable::wait: mutex not locked");
int ec = pthread_cond_wait(&__cv_, lk.mutex()->native_handle());
if (ec)
__throw_system_error(ec, "condition_variable wait failed");
}
void
condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp)
{
using namespace chrono;
if (!lk.owns_lock())
__throw_system_error(EPERM,
"condition_variable::timed wait: mutex not locked");
nanoseconds d = tp.time_since_epoch();
timespec ts;
seconds s = duration_cast<seconds>(d);
ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count());
ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
if (ec != 0 && ec != ETIMEDOUT)
__throw_system_error(ec, "condition_variable timed_wait failed");
}
_LIBCPP_END_NAMESPACE_STD

485
libcxx/src/hash.cpp Normal file
View File

@ -0,0 +1,485 @@
//===-------------------------- hash.cpp ----------------------------------===//
//
// ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊThe LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "__hash_table"
#include "algorithm"
_LIBCPP_BEGIN_NAMESPACE_STD
namespace {
// handle all next_prime(i) for i in [1, 210), special case 0
const unsigned small_primes[] =
{
0,
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
127,
131,
137,
139,
149,
151,
157,
163,
167,
173,
179,
181,
191,
193,
197,
199,
211
};
// potential primes = 210*k + indices[i], k >= 1
// these numbers are not divisible by 2, 3, 5 or 7
// (or any integer 2 <= j <= 10 for that matter).
const unsigned indices[] =
{
1,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
121,
127,
131,
137,
139,
143,
149,
151,
157,
163,
167,
169,
173,
179,
181,
187,
191,
193,
197,
199,
209
};
}
// Returns: If n == 0, returns 0. Else returns the lowest prime number that
// is greater than or equal to n.
//
// The algorithm creates a list of small primes, plus an open-ended list of
// potential primes. All prime numbers are potential prime numbers. However
// some potential prime numbers are not prime. In an ideal world, all potential
// prime numbers would be prime. Candiate prime numbers are chosen as the next
// highest potential prime. Then this number is tested for prime by dividing it
// by all potential prime numbers less than the sqrt of the candidate.
//
// This implementation defines potential primes as those numbers not divisible
// by 2, 3, 5, and 7. Other (common) implementations define potential primes
// as those not divisible by 2. A few other implementations define potential
// primes as those not divisible by 2 or 3. By raising the number of small
// primes which the potential prime is not divisible by, the set of potential
// primes more closely approximates the set of prime numbers. And thus there
// are fewer potential primes to search, and fewer potential primes to divide
// against.
size_t
__next_prime(size_t n)
{
const size_t L = 210;
const size_t N = sizeof(small_primes) / sizeof(small_primes[0]);
// If n is small enough, search in small_primes
if (n <= small_primes[N-1])
return *std::lower_bound(small_primes, small_primes + N, n);
// Else n > largest small_primes
// Start searching list of potential primes: L * k0 + indices[in]
const size_t M = sizeof(indices) / sizeof(indices[0]);
// Select first potential prime >= n
// Known a-priori n >= L
size_t k0 = n / L;
size_t in = std::lower_bound(indices, indices + M, n % L) - indices;
n = L * k0 + indices[in];
while (true)
{
// Divide n by all primes or potential primes (i) until:
// 1. The division is even, so try next potential prime.
// 2. The i > sqrt(n), in which case n is prime.
// It is known a-priori that n is not divisible by 2, 3, 5 or 7,
// so don't test those (j == 5 -> divide by 11 first). And the
// potential primes start with 211, so don't test against the last
// small prime.
for (size_t j = 5; j < N - 1; ++j)
{
if (n % small_primes[j] == 0)
goto next;
if (n / small_primes[j] < small_primes[j])
return n;
}
// n wasn't divisible by small primes, try potential primes
{
size_t i = 211;
while (true)
{
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 10;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 8;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 8;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 6;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 4;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 2;
if (n % i == 0)
break;
if (n / i < i)
return n;
i += 10;
if (n % i == 0)
break;
if (n / i < i)
return n;
// This will loop i to the next "plane" of potential primes
i += 2;
}
}
next:
// n is not prime. Increment n to next potential prime.
if (++in == M)
{
++k0;
in = 0;
}
n = L * k0 + indices[in];
}
}
_LIBCPP_END_NAMESPACE_STD

Some files were not shown because too many files have changed in this diff Show More