⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 valarray_after.h

📁 linux下编程用 编译软件
💻 H
📖 第 1 页 / 共 2 页
字号:
// The template and inlines for the -*- C++ -*- internal _Meta class.// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004// 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.// Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr>/** @file valarray_after.h *  This is an internal header file, included by other library headers. *  You should not attempt to use it directly. */#ifndef _VALARRAY_AFTER_H#define _VALARRAY_AFTER_H 1#pragma GCC system_headernamespace std{  //  // gslice_array closure.  //  template<class _Dom>    class _GBase    {    public:      typedef typename _Dom::value_type value_type;            _GBase (const _Dom& __e, const valarray<size_t>& __i)      : _M_expr (__e), _M_index(__i) {}            value_type      operator[] (size_t __i) const      { return _M_expr[_M_index[__i]]; }            size_t      size () const      { return _M_index.size(); }    private:      const _Dom&	      _M_expr;      const valarray<size_t>& _M_index;    };  template<typename _Tp>    class _GBase<_Array<_Tp> >    {    public:      typedef _Tp value_type;            _GBase (_Array<_Tp> __a, const valarray<size_t>& __i)      : _M_array (__a), _M_index(__i) {}            value_type      operator[] (size_t __i) const      { return _M_array._M_data[_M_index[__i]]; }            size_t      size () const      { return _M_index.size(); }    private:      const _Array<_Tp>       _M_array;      const valarray<size_t>& _M_index;    };  template<class _Dom>    struct _GClos<_Expr, _Dom>    : _GBase<_Dom>    {      typedef _GBase<_Dom> _Base;      typedef typename _Base::value_type value_type;            _GClos (const _Dom& __e, const valarray<size_t>& __i)      : _Base (__e, __i) {}    };  template<typename _Tp>    struct _GClos<_ValArray, _Tp>    : _GBase<_Array<_Tp> >    {      typedef _GBase<_Array<_Tp> > _Base;      typedef typename _Base::value_type value_type;            _GClos (_Array<_Tp> __a, const valarray<size_t>& __i)      : _Base (__a, __i) {}    };  //  // indirect_array closure  //  template<class _Dom>    class _IBase    {    public:      typedef typename _Dom::value_type value_type;      _IBase (const _Dom& __e, const valarray<size_t>& __i)      : _M_expr (__e), _M_index (__i) {}            value_type      operator[] (size_t __i) const      { return _M_expr[_M_index[__i]]; }            size_t      size() const      { return _M_index.size(); }    private:      const _Dom&	      _M_expr;      const valarray<size_t>& _M_index;    };  template<class _Dom>    struct _IClos<_Expr, _Dom>    : _IBase<_Dom>    {      typedef _IBase<_Dom> _Base;      typedef typename _Base::value_type value_type;            _IClos (const _Dom& __e, const valarray<size_t>& __i)      : _Base (__e, __i) {}    };  template<typename _Tp>    struct _IClos<_ValArray, _Tp>    : _IBase<valarray<_Tp> >    {      typedef _IBase<valarray<_Tp> > _Base;      typedef _Tp value_type;            _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i)      : _Base (__a, __i) {}    };    //  // class _Expr  //  template<class _Clos, typename _Tp>    class _Expr    {    public:      typedef _Tp value_type;      _Expr(const _Clos&);      const _Clos& operator()() const;      value_type operator[](size_t) const;      valarray<value_type> operator[](slice) const;      valarray<value_type> operator[](const gslice&) const;      valarray<value_type> operator[](const valarray<bool>&) const;      valarray<value_type> operator[](const valarray<size_t>&) const;      _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type>      operator+() const;      _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type>      operator-() const;      _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type>      operator~() const;      _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool>      operator!() const;      size_t size() const;      value_type sum() const;      valarray<value_type> shift(int) const;      valarray<value_type> cshift(int) const;      value_type min() const;      value_type max() const;      valarray<value_type> apply(value_type (*)(const value_type&)) const;      valarray<value_type> apply(value_type (*)(value_type)) const;    private:      const _Clos _M_closure;    };  template<class _Clos, typename _Tp>    inline    _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {}  template<class _Clos, typename _Tp>    inline const _Clos&    _Expr<_Clos, _Tp>::operator()() const    { return _M_closure; }  template<class _Clos, typename _Tp>    inline _Tp    _Expr<_Clos, _Tp>::operator[](size_t __i) const    { return _M_closure[__i]; }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::operator[](slice __s) const    {      valarray<_Tp> __v = valarray<_Tp>(*this)[__s];      return __v;    }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const    {      valarray<_Tp> __v = valarray<_Tp>(*this)[__gs];      return __v;    }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const    {      valarray<_Tp> __v = valarray<_Tp>(*this)[__m];      return __v;    }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const    {      valarray<_Tp> __v = valarray<_Tp>(*this)[__i];      return __v;    }  template<class _Clos, typename _Tp>    inline size_t    _Expr<_Clos, _Tp>::size() const    { return _M_closure.size(); }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::shift(int __n) const    {      valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n);      return __v;    }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::cshift(int __n) const    {      valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n);      return __v;    }  template<class _Clos, typename _Tp>    inline valarray<_Tp>    _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const    {      valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f);      return __v;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -