strided_base_cursor.hpp

来自「矩阵运算源码最新版本」· HPP 代码 · 共 78 行

HPP
78
字号
// Software License for MTL// // Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.// Authors: Peter Gottschling and Andrew Lumsdaine// // This file is part of the Matrix Template Library// // See also license.mtl.txt in the distribution.#ifndef MTL_STRIDED_BASE_CURSOR_INCLUDE#define MTL_STRIDED_BASE_CURSOR_INCLUDE#include <boost/numeric/mtl/detail/base_cursor.hpp>namespace mtl { namespace detail {template <class Key> struct strided_base_cursor  : base_cursor<Key>{    typedef Key                  key_type;    typedef base_cursor<Key>     base;    typedef strided_base_cursor  self;    strided_base_cursor () {}     strided_base_cursor (key_type key, std::size_t stride) 	: base(key), stride(stride)     {}    self& operator++ ()     { 	this->key+= stride; return *this;     }    self operator++ (int)     { 	self tmp = *this; 	this->key+= stride; 	return tmp;     }    self& operator-- ()     { 	this->key-= stride; 	return *this;     }    self operator-- (int)     { 	self tmp = *this; 	this->key-= stride; 	return tmp;     }    self& operator+=(int n)     { 	this->key += stride * n; 	return *this;     }    self operator+(int n) const    {	self tmp(*this);	tmp+= n;	return tmp;    }    self& operator-=(int n)     { 	this->key -= stride * n; 	return *this;     }    int operator-(const self& cc) const     {	return (this->key - cc.key) / stride;    }    std::size_t stride;};}} // namespace mtl::detail#endif // MTL_STRIDED_BASE_CURSOR_INCLUDE

⌨️ 快捷键说明

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