Reference: * Devroye, L. "Non-Uniform Random Variates Generation." Springer-Verlag, * New York, 1986, Ch. X, Sects. 3.3 & 3.4 (+ Errata!). */ template template typename poisson_distribution<_IntType, _RealType>::result_type poisson_distribution<_IntType, _RealType>:: operator()(_UniformRandomNumberGenerator& __urng) { #if _GLIBCXX_USE_C99_MATH_TR1 if (_M_mean >= 12) { _RealType __x; // See comments above... const _RealType __naf = (1 - std::numeric_limits<_RealType>::epsilon()) / 2; const _RealType __thr = std::numeric_limits<_IntType>::max() + __naf; const _RealType __m = std::floor(_M_mean); // sqrt(pi / 2) const _RealType __spi_2 = 1.2533141373155002512078826424055226L; const _RealType __c1 = _M_sm * __spi_2; const _RealType __c2 = _M_c2b + __c1; const _RealType __c3 = __c2 + 1; const _RealType __c4 = __c3 + 1; // e^(1 / 78) const _RealType __e178 = 1.0129030479320018583185514777512983L; const _RealType __c5 = __c4 + __e178; const _RealType __c = _M_cb + __c5; const _RealType __2cx = 2 * (2 * __m + _M_d); bool __reject = true; do { const _RealType __u = __c * __urng(); const _RealType __e = -std::log(__urng()); _RealType __w = 0.0; if (__u <= __c1) { const _RealType __n = _M_nd(__urng); const _RealType __y = -std::abs(__n) * _M_sm - 1; __x = std::floor(__y); __w = -__n * __n / 2; if (__x < -__m) continue; } else if (__u <= __c2) { const _RealType __n = _M_nd(__urng); const _RealType __y = 1 + std::abs(__n) * _M_scx; __x = std::ceil(__y); __w = __y * (2 - __y) * _M_1cx; if (__x > _M_d) continue; } else if (__u <= __c3) // NB: This case not in the book, nor in the Errata, // but should be ok... __x = -1; else if (__u <= __c4) __x = 0; else if (__u <= __c5) __x = 1; else { const _RealType __v = -std::log(__urng()); const _RealType __y = _M_d + __v * __2cx / _M_d; __x = std::ceil(__y); __w = -_M_d * _M_1cx * (1 + __y / 2); } __reject = (__w - __e - __x * _M_lm_thr > _M_lfm - std::_GLIBCXX_TR1 lgamma(__x + __m + 1)); __reject |= __x + __m >= __thr; } while (__reject); return result_type(__x + __m + __naf); } else #endif { _IntType __x = 0; _RealType __prod = 1.0; do { __prod *= __urng(); __x += 1; } while (__prod > _M_lm_thr); return __x - 1; } } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const poisson_distribution<_IntType, _RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); const _CharT __space = __os.widen(' '); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__space); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x.mean() << __space << __x._M_nd; __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, poisson_distribution<_IntType, _RealType>& __x) { typedef std::basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __is.flags(); __is.flags(__ios_base::skipws); __is >> __x._M_mean >> __x._M_nd; __x._M_initialize(); __is.flags(__flags); return __is; } template void binomial_distribution<_IntType, _RealType>:: _M_initialize() { const _RealType __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p; _M_easy = true; #if _GLIBCXX_USE_C99_MATH_TR1 if (_M_t * __p12 >= 8) { _M_easy = false; const _RealType __np = std::floor(_M_t * __p12); const _RealType __pa = __np / _M_t; const _RealType __1p = 1 - __pa; const _RealType __pi_4 = 0.7853981633974483096156608458198757L; const _RealType __d1x = std::sqrt(__np * __1p * std::log(32 * __np / (81 * __pi_4 * __1p))); _M_d1 = std::_GLIBCXX_TR1 round(std::max(_RealType(1), __d1x)); const _RealType __d2x = std::sqrt(__np * __1p * std::log(32 * _M_t * __1p / (__pi_4 * __pa))); _M_d2 = std::_GLIBCXX_TR1 round(std::max(_RealType(1), __d2x)); // sqrt(pi / 2) const _RealType __spi_2 = 1.2533141373155002512078826424055226L; _M_s1 = std::sqrt(__np * __1p) * (1 + _M_d1 / (4 * __np)); _M_s2 = std::sqrt(__np * __1p) * (1 + _M_d2 / (4 * _M_t * __1p)); _M_c = 2 * _M_d1 / __np; _M_a1 = std::exp(_M_c) * _M_s1 * __spi_2; const _RealType __a12 = _M_a1 + _M_s2 * __spi_2; const _RealType __s1s = _M_s1 * _M_s1; _M_a123 = __a12 + (std::exp(_M_d1 / (_M_t * __1p)) * 2 * __s1s / _M_d1 * std::exp(-_M_d1 * _M_d1 / (2 * __s1s))); const _RealType __s2s = _M_s2 * _M_s2; _M_s = (_M_a123 + 2 * __s2s / _M_d2 * std::exp(-_M_d2 * _M_d2 / (2 * __s2s))); _M_lf = (std::_GLIBCXX_TR1 lgamma(__np + 1) + std::_GLIBCXX_TR1 lgamma(_M_t - __np + 1)); _M_lp1p = std::log(__pa / __1p); _M_q = -std::log(1 - (__p12 - __pa) / __1p); } else #endif _M_q = -std::log(1 - __p12); } template template typename binomial_distribution<_IntType, _RealType>::result_type binomial_distribution<_IntType, _RealType>:: _M_waiting(_UniformRandomNumberGenerator& __urng, _IntType __t) { _IntType __x = 0; _RealType __sum = 0; do { const _RealType __e = -std::log(__urng()); __sum += __e / (__t - __x); __x += 1; } while (__sum <= _M_q); return __x - 1; } /** * A rejection algorithm when t * p >= 8 and a simple waiting time * method - the second in the referenced book - otherwise. * NB: The former is available only if _GLIBCXX_USE_C99_MATH_TR1 * is defined. * * Reference: * Devroye, L. "Non-Uniform Random Variates Generation." Springer-Verlag, * New York, 1986, Ch. X, Sect. 4 (+ Errata!). */ template template typename binomial_distribution<_IntType, _RealType>::result_type binomial_distribution<_IntType, _RealType>:: operator()(_UniformRandomNumberGenerator& __urng) { result_type __ret; const _RealType __p12 = _M_p <= 0.5 ? _M_p : 1.0 - _M_p; #if _GLIBCXX_USE_C99_MATH_TR1 if (!_M_easy) { _RealType __x; // See comments above... const _RealType __naf = (1 - std::numeric_limits<_RealType>::epsilon()) / 2; const _RealType __thr = std::numeric_limits<_IntType>::max() + __naf; const _RealType __np = std::floor(_M_t * __p12); const _RealType __pa = __np / _M_t; // sqrt(pi / 2) const _RealType __spi_2 = 1.2533141373155002512078826424055226L; const _RealType __a1 = _M_a1; const _RealType __a12 = __a1 + _M_s2 * __spi_2; const _RealType __a123 = _M_a123; const _RealType __s1s = _M_s1 * _M_s1; const _RealType __s2s = _M_s2 * _M_s2; bool __reject; do { const _RealType __u = _M_s * __urng(); _RealType __v; if (__u <= __a1) { const _RealType __n = _M_nd(__urng); const _RealType __y = _M_s1 * std::abs(__n); __reject = __y >= _M_d1; if (!__reject) { const _RealType __e = -std::log(__urng()); __x = std::floor(__y); __v = -__e - __n * __n / 2 + _M_c; } } else if (__u <= __a12) { const _RealType __n = _M_nd(__urng); const _RealType __y = _M_s2 * std::abs(__n); __reject = __y >= _M_d2; if (!__reject) { const _RealType __e = -std::log(__urng()); __x = std::floor(-__y); __v = -__e - __n * __n / 2; } } else if (__u <= __a123) { const _RealType __e1 = -std::log(__urng()); const _RealType __e2 = -std::log(__urng()); const _RealType __y = _M_d1 + 2 * __s1s * __e1 / _M_d1; __x = std::floor(__y); __v = (-__e2 + _M_d1 * (1 / (_M_t - __np) -__y / (2 * __s1s))); __reject = false; } else { const _RealType __e1 = -std::log(__urng()); const _RealType __e2 = -std::log(__urng()); const _RealType __y = _M_d2 + 2 * __s2s * __e1 / _M_d2; __x = std::floor(-__y); __v = -__e2 - _M_d2 * __y / (2 * __s2s); __reject = false; } __reject = __reject || __x < -__np || __x > _M_t - __np; if (!__reject) { const _RealType __lfx = std::_GLIBCXX_TR1 lgamma(__np + __x + 1) + std::_GLIBCXX_TR1 lgamma(_M_t - (__np + __x) + 1); __reject = __v > _M_lf - __lfx + __x * _M_lp1p; } __reject |= __x + __np >= __thr; } while (__reject); __x += __np + __naf; const _IntType __z = _M_waiting(__urng, _M_t - _IntType(__x)); __ret = _IntType(__x) + __z; } else #endif __ret = _M_waiting(__urng, _M_t); if (__p12 != _M_p) __ret = _M_t - __ret; return __ret; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const binomial_distribution<_IntType, _RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); const _CharT __space = __os.widen(' '); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__space); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x.t() << __space << __x.p() << __space << __x._M_nd; __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, binomial_distribution<_IntType, _RealType>& __x) { typedef std::basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __is.flags(); __is.flags(__ios_base::dec | __ios_base::skipws); __is >> __x._M_t >> __x._M_p >> __x._M_nd; __x._M_initialize(); __is.flags(__flags); return __is; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const uniform_real<_RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); const _CharT __space = __os.widen(' '); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__space); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x.min() << __space << __x.max(); __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, uniform_real<_RealType>& __x) { typedef std::basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __is.flags(); __is.flags(__ios_base::skipws); __is >> __x._M_min >> __x._M_max; __is.flags(__flags); return __is; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const exponential_distribution<_RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__os.widen(' ')); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x.lambda(); __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } /** * Polar method due to Marsaglia. * * Devroye, L. "Non-Uniform Random Variates Generation." Springer-Verlag, * New York, 1986, Ch. V, Sect. 4.4. */ template template typename normal_distribution<_RealType>::result_type normal_distribution<_RealType>:: operator()(_UniformRandomNumberGenerator& __urng) { result_type __ret; if (_M_saved_available) { _M_saved_available = false; __ret = _M_saved; } else { result_type __x, __y, __r2; do { __x = result_type(2.0) * __urng() - 1.0; __y = result_type(2.0) * __urng() - 1.0; __r2 = __x * __x + __y * __y; } while (__r2 > 1.0 || __r2 == 0.0); const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); _M_saved = __x * __mult; _M_saved_available = true; __ret = __y * __mult; } __ret = __ret * _M_sigma + _M_mean; return __ret; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const normal_distribution<_RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); const _CharT __space = __os.widen(' '); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__space); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x._M_saved_available << __space << __x.mean() << __space << __x.sigma(); if (__x._M_saved_available) __os << __space << __x._M_saved; __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } template std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, normal_distribution<_RealType>& __x) { typedef std::basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __is.flags(); __is.flags(__ios_base::dec | __ios_base::skipws); __is >> __x._M_saved_available >> __x._M_mean >> __x._M_sigma; if (__x._M_saved_available) __is >> __x._M_saved; __is.flags(__flags); return __is; } template void gamma_distribution<_RealType>:: _M_initialize() { if (_M_alpha >= 1) _M_l_d = std::sqrt(2 * _M_alpha - 1); else _M_l_d = (std::pow(_M_alpha, _M_alpha / (1 - _M_alpha)) * (1 - _M_alpha)); } /** * Cheng's rejection algorithm GB for alpha >= 1 and a modification * of Vaduva's rejection from Weibull algorithm due to Devroye for * alpha < 1. * * References: * Cheng, R. C. "The Generation of Gamma Random Variables with Non-integral * Shape Parameter." Applied Statistics, 26, 71-75, 1977. * * Vaduva, I. "Computer Generation of Gamma Gandom Variables by Rejection * and Composition Procedures." Math. Operationsforschung and Statistik, * Series in Statistics, 8, 545-576, 1977. * * Devroye, L. "Non-Uniform Random Variates Generation." Springer-Verlag, * New York, 1986, Ch. IX, Sect. 3.4 (+ Errata!). */ template template typename gamma_distribution<_RealType>::result_type gamma_distribution<_RealType>:: operator()(_UniformRandomNumberGenerator& __urng) { result_type __x; bool __reject; if (_M_alpha >= 1) { // alpha - log(4) const result_type __b = _M_alpha - result_type(1.3862943611198906188344642429163531L); const result_type __c = _M_alpha + _M_l_d; const result_type __1l = 1 / _M_l_d; // 1 + log(9 / 2) const result_type __k = 2.5040773967762740733732583523868748L; do { const result_type __u = __urng(); const result_type __v = __urng(); const result_type __y = __1l * std::log(__v / (1 - __v)); __x = _M_alpha * std::exp(__y); const result_type __z = __u * __v * __v; const result_type __r = __b + __c * __y - __x; __reject = __r < result_type(4.5) * __z - __k; if (__reject) __reject = __r < std::log(__z); } while (__reject); } else { const result_type __c = 1 / _M_alpha; do { const result_type __z = -std::log(__urng()); const result_type __e = -std::log(__urng()); __x = std::pow(__z, __c); __reject = __z + __e < _M_l_d + __x; } while (__reject); } return __x; } template std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const gamma_distribution<_RealType>& __x) { typedef std::basic_ostream<_CharT, _Traits> __ostream_type; typedef typename __ostream_type::ios_base __ios_base; const typename __ios_base::fmtflags __flags = __os.flags(); const _CharT __fill = __os.fill(); const std::streamsize __precision = __os.precision(); __os.flags(__ios_base::scientific | __ios_base::left); __os.fill(__os.widen(' ')); __os.precision(__gnu_cxx::__numeric_traits<_RealType>::__max_digits10); __os << __x.alpha(); __os.flags(__flags); __os.fill(__fill); __os.precision(__precision); return __os; } _GLIBCXX_END_NAMESPACE_TR1 } // TR1 cinttypes -*- C++ -*- // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1_impl/cinttypes * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ #pragma GCC system_header #if _GLIBCXX_USE_C99_INTTYPES_TR1 namespace std { _GLIBCXX_BEGIN_NAMESPACE_TR1 // types using ::imaxdiv_t; // functions using ::imaxabs; // May collide with _Longlong abs(_Longlong), and is not described // anywhere outside the synopsis. Likely, a defect. // // intmax_t abs(intmax_t) using ::imaxdiv; // Likewise, with lldiv_t div(_Longlong, _Longlong). // // imaxdiv_t div(intmax_t, intmax_t) using ::strtoimax; using ::strtoumax; #ifdef _GLIBCXX_USE_WCHAR_T using ::wcstoimax; using ::wcstoumax; #endif _GLIBCXX_END_NAMESPACE_TR1 } #endif // TR1 type_traits -*- C++ -*- // Copyright (C) 2007, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1_impl/type_traits * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ namespace std { _GLIBCXX_BEGIN_NAMESPACE_TR1 // For use in __is_convertible_simple. struct __sfinae_types { typedef char __one; typedef struct { char __arr[2]; } __two; }; #define _DEFINE_SPEC_BODY(_Value) \ : public integral_constant { }; #define _DEFINE_SPEC_0_HELPER(_Spec, _Value) \ template<> \ struct _Spec \ _DEFINE_SPEC_BODY(_Value) #define _DEFINE_SPEC_1_HELPER(_Spec, _Value) \ template \ struct _Spec \ _DEFINE_SPEC_BODY(_Value) #define _DEFINE_SPEC_2_HELPER(_Spec, _Value) \ template \ struct _Spec \ _DEFINE_SPEC_BODY(_Value) #define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \ _DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type>, _Value) \ _DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type const>, _Value) \ _DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type volatile>, _Value) \ _DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type const volatile>, _Value) /// helper classes [4.3]. template struct integral_constant { static const _Tp value = __v; typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; }; /// typedef for true_type typedef integral_constant true_type; /// typedef for true_type typedef integral_constant false_type; template const _Tp integral_constant<_Tp, __v>::value; /// primary type categories [4.5.1]. template struct is_void : public false_type { }; _DEFINE_SPEC(0, is_void, void, true) /// is_integral template struct is_integral : public false_type { }; _DEFINE_SPEC(0, is_integral, bool, true) _DEFINE_SPEC(0, is_integral, char, true) _DEFINE_SPEC(0, is_integral, signed char, true) _DEFINE_SPEC(0, is_integral, unsigned char, true) #ifdef _GLIBCXX_USE_WCHAR_T _DEFINE_SPEC(0, is_integral, wchar_t, true) #endif _DEFINE_SPEC(0, is_integral, short, true) _DEFINE_SPEC(0, is_integral, unsigned short, true) _DEFINE_SPEC(0, is_integral, int, true) _DEFINE_SPEC(0, is_integral, unsigned int, true) _DEFINE_SPEC(0, is_integral, long, true) _DEFINE_SPEC(0, is_integral, unsigned long, true) _DEFINE_SPEC(0, is_integral, long long, true) _DEFINE_SPEC(0, is_integral, unsigned long long, true) /// is_floating_point template struct is_floating_point : public false_type { }; _DEFINE_SPEC(0, is_floating_point, float, true) _DEFINE_SPEC(0, is_floating_point, double, true) _DEFINE_SPEC(0, is_floating_point, long double, true) /// is_array template struct is_array : public false_type { }; template struct is_array<_Tp[_Size]> : public true_type { }; template struct is_array<_Tp[]> : public true_type { }; /// is_pointer template struct is_pointer : public false_type { }; _DEFINE_SPEC(1, is_pointer, _Tp*, true) /// is_reference template struct is_reference; /// is_function template struct is_function; /// is_member_object_pointer template struct is_member_object_pointer : public false_type { }; _DEFINE_SPEC(2, is_member_object_pointer, _Tp _Cp::*, !is_function<_Tp>::value) /// is_member_function_pointer template struct is_member_function_pointer : public false_type { }; _DEFINE_SPEC(2, is_member_function_pointer, _Tp _Cp::*, is_function<_Tp>::value) /// is_enum template struct is_enum : public integral_constant { }; /// is_union template struct is_union : public integral_constant { }; /// is_class template struct is_class : public integral_constant { }; template struct __in_array : public __sfinae_types { private: template static __one __test(_Up(*)[1]); template static __two __test(...); public: static const bool __value = sizeof(__test<_Tp>(0)) == 1; }; /// is_abstract template struct is_abstract; /// is_function template struct is_function : public integral_constant::__value || is_abstract<_Tp>::value || is_reference<_Tp>::value || is_void<_Tp>::value)> { }; /// composite type traits [4.5.2]. template struct is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value)> { }; /// is_fundamental template struct is_fundamental : public integral_constant::value || is_void<_Tp>::value)> { }; /// is_object template struct is_object : public integral_constant::value || is_reference<_Tp>::value || is_void<_Tp>::value)> { }; /// is_member_pointer template struct is_member_pointer; /// is_scalal template struct is_scalar : public integral_constant::value || is_enum<_Tp>::value || is_pointer<_Tp>::value || is_member_pointer<_Tp>::value)> { }; /// is_compound template struct is_compound : public integral_constant::value> { }; /// is_member_pointer template struct is_member_pointer : public integral_constant::value || is_member_function_pointer<_Tp>::value)> { }; /// type properties [4.5.3]. template struct is_const : public false_type { }; /// is_const template struct is_const<_Tp const> : public true_type { }; /// is_volatile template struct is_volatile : public false_type { }; template struct is_volatile<_Tp volatile> : public true_type { }; /// is_empty template struct is_empty : public integral_constant { }; /// is_polymorphic template struct is_polymorphic : public integral_constant { }; /// is_abstract template struct is_abstract : public integral_constant { }; /// has_virtual_destructor template struct has_virtual_destructor : public integral_constant { }; /// alignment_of template struct alignment_of : public integral_constant { }; /// rank template struct rank : public integral_constant { }; template struct rank<_Tp[_Size]> : public integral_constant::value> { }; template struct rank<_Tp[]> : public integral_constant::value> { }; /// extent template struct extent : public integral_constant { }; template struct extent<_Tp[_Size], _Uint> : public integral_constant::value> { }; template struct extent<_Tp[], _Uint> : public integral_constant::value> { }; /// relationships between types [4.6]. template struct is_same : public false_type { }; template struct is_same<_Tp, _Tp> : public true_type { }; /// const-volatile modifications [4.7.1]. template struct remove_const { typedef _Tp type; }; template struct remove_const<_Tp const> { typedef _Tp type; }; /// remove_volatile template struct remove_volatile { typedef _Tp type; }; template struct remove_volatile<_Tp volatile> { typedef _Tp type; }; /// remove_cv template struct remove_cv { typedef typename remove_const::type>::type type; }; /// add_const template struct add_const { typedef _Tp const type; }; /// add_volatile template struct add_volatile { typedef _Tp volatile type; }; /// add_cv template struct add_cv { typedef typename add_const::type>::type type; }; /// array modifications [4.7.3]. template struct remove_extent { typedef _Tp type; }; template struct remove_extent<_Tp[_Size]> { typedef _Tp type; }; template struct remove_extent<_Tp[]> { typedef _Tp type; }; /// remove_all_extents template struct remove_all_extents { typedef _Tp type; }; template struct remove_all_extents<_Tp[_Size]> { typedef typename remove_all_extents<_Tp>::type type; }; template struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; /// pointer modifications [4.7.4]. #undef _DEFINE_SPEC_BODY #define _DEFINE_SPEC_BODY(_Value) \ { typedef _Tp type; }; /// remove_pointer template struct remove_pointer { typedef _Tp type; }; _DEFINE_SPEC(1, remove_pointer, _Tp*, false) /// remove_reference template struct remove_reference; /// add_pointer template struct add_pointer { typedef typename remove_reference<_Tp>::type* £/ type; }; #undef _DEFINE_SPEC_0_HELPER #undef _DEFINE_SPEC_1_HELPER #undef _DEFINE_SPEC_2_HELPER #undef _DEFINE_SPEC #undef _DEFINE_SPEC_BODY _GLIBCXX_END_NAMESPACE_TR1 } // TR1 cmath -*- C++ -*- // Copyright (C) 2007 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1_impl/cmath * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ #if _GLIBCXX_USE_C99_MATH_TR1 #undef acosh #undef acoshf #undef acoshl #undef asinh #undef asinhf #undef asinhl #undef atanh #undef atanhf #undef atanhl #undef cbrt #undef cbrtf #undef cbrtl #undef copysign #undef copysignf #undef copysignl #undef erf #undef erff #undef erfl #undef erfc #undef erfcf #undef erfcl #undef exp2 #undef exp2f #undef exp2l #undef expm1 #undef expm1f #undef expm1l #undef fdim #undef fdimf #undef fdiml #undef fma #undef fmaf #undef fmal #undef fmax #undef fmaxf #undef fmaxl #undef fmin #undef fminf #undef fminl #undef hypot #undef hypotf #undef hypotl #undef ilogb #undef ilogbf #undef ilogbl #undef lgamma #undef lgammaf #undef lgammal #undef llrint #undef llrintf #undef llrintl #undef llround #undef llroundf #undef llroundl #undef log1p #undef log1pf #undef log1pl #undef log2 #undef log2f #undef log2l #undef logb #undef logbf #undef logbl #undef lrint #undef lrintf #undef lrintl #undef lround #undef lroundf #undef lroundl #undef nan #undef nanf #undef nanl #undef nearbyint #undef nearbyintf #undef nearbyintl #undef nextafter #undef nextafterf #undef nextafterl #undef nexttoward #undef nexttowardf #undef nexttowardl #undef remainder #undef remainderf #undef remainderl #undef remquo #undef remquo #undef remquo #undef rint #undef rintf #undef rintl #undef round #undef roundf #undef roundl #undef scalbln #undef scalblnf #undef scalblnl #undef scalbn #undef scalbnf #undef scalbnl #undef tgamma #undef tgammaf #undef tgammal #undef trunc #undef truncf #undef truncl #endif namespace std { _GLIBCXX_BEGIN_NAMESPACE_TR1 #if _GLIBCXX_USE_C99_MATH_TR1 // types using ::double_t; using ::float_t; // functions using ::acosh; using ::acoshf; using ::acoshl; using ::asinh; using ::asinhf; using ::asinhl; using ::atanh; using ::atanhf; using ::atanhl; using ::cbrt; using ::cbrtf; using ::cbrtl; using ::copysign; using ::copysignf; using ::copysignl; using ::erf; using ::erff; using ::erfl; using ::erfc; using ::erfcf; using ::erfcl; using ::exp2; using ::exp2f; using ::exp2l; using ::expm1; using ::expm1f; using ::expm1l; using ::fdim; using ::fdimf; using ::fdiml; using ::fma; using ::fmaf; using ::fmal; using ::fmax; using ::fmaxf; using ::fmaxl; using ::fmin; using ::fminf; using ::fminl; using ::hypot; using ::hypotf; using ::hypotl; using ::ilogb; using ::ilogbf; using ::ilogbl; using ::lgamma; using ::lgammaf; using ::lgammal; using ::llrint; using ::llrintf; using ::llrintl; using ::llround; using ::llroundf; using ::llroundl; using ::log1p; using ::log1pf; using ::log1pl; using ::log2; using ::log2f; using ::log2l; using ::logb; using ::logbf; using ::logbl; using ::lrint; using ::lrintf; using ::lrintl; using ::lround; using ::lroundf; using ::lroundl; using ::nan; using ::nanf; using ::nanl; using ::nearbyint; using ::nearbyintf; using ::nearbyintl; using ::nextafter; using ::nextafterf; using ::nextafterl; using ::nexttoward; using ::nexttowardf; using ::nexttowardl; using ::remainder; using ::remainderf; using ::remainderl; using ::remquo; using ::remquo; using ::remquo; using ::rint; using ::rintf; using ::rintl; using ::round; using ::roundf; using ::roundl; using ::scalbln; using ::scalblnf; using ::scalblnl; using ::scalbn; using ::scalbnf; using ::scalbnl; using ::tgamma; using ::tgammaf; using ::tgammal; using ::trunc; using ::truncf; using ::truncl; #endif #if _GLIBCXX_USE_C99_MATH #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC /// Function template definitions [8.16.3]. using std::signbit; using std::fpclassify; using std::isfinite; using std::isinf; using std::isnan; using std::isnormal; using std::isgreater; using std::isgreaterequal; using std::isless; using std::islessequal; using std::islessgreater; using std::isunordered; #endif #endif #if _GLIBCXX_USE_C99_MATH_TR1 /// Additional overloads [8.16.4]. using std::acos; inline float acosh(float __x) { return __builtin_acoshf(__x); } inline long double acosh(long double __x) { return __builtin_acoshl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type acosh(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return acosh(__type(__x)); } using std::asin; inline float asinh(float __x) { return __builtin_asinhf(__x); } inline long double asinh(long double __x) { return __builtin_asinhl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type asinh(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return asinh(__type(__x)); } using std::atan; using std::atan2; inline float atanh(float __x) { return __builtin_atanhf(__x); } inline long double atanh(long double __x) { return __builtin_atanhl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type atanh(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return atanh(__type(__x)); } inline float cbrt(float __x) { return __builtin_cbrtf(__x); } inline long double cbrt(long double __x) { return __builtin_cbrtl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type cbrt(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return cbrt(__type(__x)); } using std::ceil; inline float copysign(float __x, float __y) { return __builtin_copysignf(__x, __y); } inline long double copysign(long double __x, long double __y) { return __builtin_copysignl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type copysign(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return copysign(__type(__x), __type(__y)); } using std::cos; using std::cosh; inline float erf(float __x) { return __builtin_erff(__x); } inline long double erf(long double __x) { return __builtin_erfl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type erf(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return erf(__type(__x)); } inline float erfc(float __x) { return __builtin_erfcf(__x); } inline long double erfc(long double __x) { return __builtin_erfcl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type erfc(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return erfc(__type(__x)); } using std::exp; inline float exp2(float __x) { return __builtin_exp2f(__x); } inline long double exp2(long double __x) { return __builtin_exp2l(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type exp2(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return exp2(__type(__x)); } inline float expm1(float __x) { return __builtin_expm1f(__x); } inline long double expm1(long double __x) { return __builtin_expm1l(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type expm1(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return expm1(__type(__x)); } using std::fabs; inline float fdim(float __x, float __y) { return __builtin_fdimf(__x, __y); } inline long double fdim(long double __x, long double __y) { return __builtin_fdiml(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fdim(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fdim(__type(__x), __type(__y)); } using std::floor; inline float fma(float __x, float __y, float __z) { return __builtin_fmaf(__x, __y, __z); } inline long double fma(long double __x, long double __y, long double __z) { return __builtin_fmal(__x, __y, __z); } template inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type fma(_Tp __x, _Up __y, _Vp __z) { typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; return fma(__type(__x), __type(__y), __type(__z)); } inline float fmax(float __x, float __y) { return __builtin_fmaxf(__x, __y); } inline long double fmax(long double __x, long double __y) { return __builtin_fmaxl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fmax(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fmax(__type(__x), __type(__y)); } inline float fmin(float __x, float __y) { return __builtin_fminf(__x, __y); } inline long double fmin(long double __x, long double __y) { return __builtin_fminl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type fmin(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return fmin(__type(__x), __type(__y)); } using std::fmod; using std::frexp; inline float hypot(float __x, float __y) { return __builtin_hypotf(__x, __y); } inline long double hypot(long double __x, long double __y) { return __builtin_hypotl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type hypot(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return hypot(__type(__x), __type(__y)); } inline int ilogb(float __x) { return __builtin_ilogbf(__x); } inline int ilogb(long double __x) { return __builtin_ilogbl(__x); } template inline int ilogb(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return ilogb(__type(__x)); } using std::ldexp; inline float lgamma(float __x) { return __builtin_lgammaf(__x); } inline long double lgamma(long double __x) { return __builtin_lgammal(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type lgamma(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return lgamma(__type(__x)); } inline long long llrint(float __±/²/³/´/µ/¶/·/¸/x) { return __builtin_llrintf(__x); } inline long long llrint(long double __x) { return __builtin_llrintl(__x); } template inline long long llrint(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return llrint(__type(__x)); } inline long long llround(float __x) { return __builtin_llroundf(__x); } inline long long llround(long double __x) { return __builtin_llroundl(__x); } template inline long long llround(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return llround(__type(__x)); } using std::log; using std::log10; inline float log1p(float __x) { return __builtin_log1pf(__x); } inline long double log1p(long double __x) { return __builtin_log1pl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type log1p(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return log1p(__type(__x)); } // DR 568. inline float log2(float __x) { return __builtin_log2f(__x); } inline long double log2(long double __x) { return __builtin_log2l(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type log2(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return log2(__type(__x)); } inline float logb(float __x) { return __builtin_logbf(__x); } inline long double logb(long double __x) { return __builtin_logbl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type logb(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return logb(__type(__x)); } inline long lrint(float __x) { return __builtin_lrintf(__x); } inline long lrint(long double __x) { return __builtin_lrintl(__x); } template inline long lrint(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return lrint(__type(__x)); } inline long lround(float __x) { return __builtin_lroundf(__x); } inline long lround(long double __x) { return __builtin_lroundl(__x); } template inline long lround(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return lround(__type(__x)); } inline float nearbyint(float __x) { return __builtin_nearbyintf(__x); } inline long double nearbyint(long double __x) { return __builtin_nearbyintl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type nearbyint(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return nearbyint(__type(__x)); } inline float nextafter(float __x, float __y) { return __builtin_nextafterf(__x, __y); } inline long double nextafter(long double __x, long double __y) { return __builtin_nextafterl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type nextafter(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return nextafter(__type(__x), __type(__y)); } inline float nexttoward(float __x, long double __y) { return __builtin_nexttowardf(__x, __y); } inline long double nexttoward(long double __x, long double __y) { return __builtin_nexttowardl(__x, __y); } template inline typename __gnu_cxx::__promote<_Tp>::__type nexttoward(_Tp __x, long double __y) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return nexttoward(__type(__x), __y); } using std::pow; inline float remainder(float __x, float __y) { return __builtin_remainderf(__x, __y); } inline long double remainder(long double __x, long double __y) { return __builtin_remainderl(__x, __y); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type remainder(_Tp __x, _Up __y) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return remainder(__type(__x), __type(__y)); } inline float remquo(float __x, float __y, int* __pquo) { return __builtin_remquof(__x, __y, __pquo); } inline long double remquo(long double __x, long double __y, int* __pquo) { return __builtin_remquol(__x, __y, __pquo); } template inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type remquo(_Tp __x, _Up __y, int* __pquo) { typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; return remquo(__type(__x), __type(__y), __pquo); } inline float rint(float __x) { return __builtin_rintf(__x); } inline long double rint(long double __x) { return __builtin_rintl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type rint(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return rint(__type(__x)); } inline float round(float __x) { return __builtin_roundf(__x); } inline long double round(long double __x) { return __builtin_roundl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type round(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return round(__type(__x)); } inline float scalbln(float __x, long __ex) { return __builtin_scalblnf(__x, __ex); } inline long double scalbln(long double __x, long __ex) { return __builtin_scalblnl(__x, __ex); } template inline typename __gnu_cxx::__promote<_Tp>::__type scalbln(_Tp __x, long __ex) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return scalbln(__type(__x), __ex); } inline float scalbn(float __x, int __ex) { return __builtin_scalbnf(__x, __ex); } inline long double scalbn(long double __x, int __ex) { return __builtin_scalbnl(__x, __ex); } template inline typename __gnu_cxx::__promote<_Tp>::__type scalbn(_Tp __x, int __ex) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return scalbn(__type(__x), __ex); } using std::sin; using std::sinh; using std::sqrt; using std::tan; using std::tanh; inline float tgamma(float __x) { return __builtin_tgammaf(__x); } inline long double tgamma(long double __x) { return __builtin_tgammal(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type tgamma(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return tgamma(__type(__x)); } inline float trunc(float __x) { return __builtin_truncf(__x); } inline long double trunc(long double __x) { return __builtin_truncl(__x); } template inline typename __gnu_cxx::__promote<_Tp>::__type trunc(_Tp __x) { typedef typename __gnu_cxx::__promote<_Tp>::__type __type; return trunc(__type(__x)); } #endif _GLIBCXX_END_NAMESPACE_TR1 } // TR1 functional header -*- C++ -*- // Copyright (C) 2007, 2008 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 2, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING. If not, write to the Free // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software // library without restriction. Specifically, if other files instantiate // templates or use macros or inline functions from this file, or you compile // this file and link it with other files to produce an executable, this // file does not by itself cause the resulting executable to be covered by // the GNU General Public License. This exception does not however // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. /** @file tr1_impl/functional * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ namespace std { _GLIBCXX_BEGIN_NAMESPACE_TR1 template class _Mem_fn; /** * Actual implementation of _Has_result_type, which uses SFINAE to * determine if the type _Tp has a publicly-accessible member type * result_type. */ template class _Has_result_type_helper : __sfinae_types { template struct _Wrap_type { }; template static __one __test(_Wrap_type*); template static __two __test(...); public: static const bool value = sizeof(__test<_Tp>(0)) == 1; }; template struct _Has_result_type : integral_constant::type>::value> { }; /** * */ /// If we have found a result_type, extract it. template struct _Maybe_get_result_type { }; template struct _Maybe_get_result_type { typedef typename _Functor::result_type result_type; }; /** * Base class for any function object that has a weak result type, as * defined in 3.3/3 of TR1. */ template struct _Weak_result_type_impl : _Maybe_get_result_type<_Has_result_type<_Functor>::value, _Functor> { }; /// Retrieve the result type for a function type. template struct _Weak_result_type_impl<_Res(_ArgTypes...)> { typedef _Res result_type; }; /// Retrieve the result type for a function reference. template struct _Weak_result_type_impl<_Res(&)(_ArgTypes...)> { typedef _Res result_type; }; /// Retrieve the result type for a function pointer. template struct _Weak_result_type_impl<_Res(*)(_ArgTypes...)> { typedef _Res result_type; }; /// Retrieve result type for a member function pointer. template struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...)> { typedef _Res result_type; }; /// Retrieve result type for a const member function pointer. template struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...) const> { typedef _Res result_type; }; /// Retrieve result type for a volatile member function pointer. template struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...) volatile> { typedef _Res result_type; }; /// Retrieve result type for a const volatile member function pointer. template struct _Weak_result_type_impl<_Res (_Class::*)(_ArgTypes...)const volatile> { typedef _Res result_type; }; /** * Strip top-level cv-qualifiers from the function object and let * _Weak_result_type_impl perform the real work. */ template struct _Weak_result_type : _Weak_result_type_impl::type> { }; template class result_of; /** * Actual implementation of result_of. When _Has_result_type is * true, gets its result from _Weak_result_type. Otherwise, uses * the function object's member template result to extract the * result type. */ template struct _Result_of_impl; // Handle member data pointers using _Mem_fn's logic template struct _Result_of_impl { typedef typename _Mem_fn<_Res _Class::*> ::template _Result_type<_T1>::type type; }; /** * Determine whether we can determine a result type from @c Functor * alone. */ template class result_of<_Functor(_ArgTypes...)> : public _Result_of_impl< _Has_result_type<_Weak_result_type<_Functor> >::value, _Functor(_ArgTypes...)> { }; /// We already know the result type for @c Functor; use it. template struct _Result_of_impl { typedef typename _Weak_result_type<_Functor>::result_type type; }; /** * We need to compute the result type for this invocation the hard * way. */ template struct _Result_of_impl { typedef typename _Functor ::template result<_Functor(_ArgTypes...)>::type type; }; /** * It is unsafe to access ::result when there are zero arguments, so we * return @c void instead. */ template struct _Result_of_impl { typedef void type; }; /// Determines if the type _Tp derives from unary_function. template struct _Derives_from_unary_function : __sfinae_types { private: template static __one __test(const volatile unary_function<_T1, _Res>*); // It's tempting to change "..." to const volatile void*, but // that fails when _Tp is a function type. static __two __test(...); public: static const bool value =