📄 noalias.hpp
字号:
//
// Copyright (c) 2003
// Michael Stevens
//
// Permission to use, copy, modify, distribute and sell this software
// and its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appear in all copies and
// that both that copyright notice and this permission notice appear
// in supporting documentation. The authors make no representations
// about the suitability of this software for any purpose.
// It is provided "as is" without express or implied warranty.
//
#ifndef BOOST_UBLAS_NOALIAS_H
#define BOOST_UBLAS_NOALIAS_H
namespace boost { namespace numeric { namespace ublas {
// Assignment proxy.
// Provides temporary free assigment when LHS has no alias on RHS
template<class C>
class noalias_proxy:
private boost::nonassignable {
public:
typedef typename C::closure_type closure_type;
BOOST_UBLAS_INLINE
noalias_proxy (C& lval):
boost::nonassignable (), lval_ (lval) {}
BOOST_UBLAS_INLINE
noalias_proxy (const noalias_proxy& p):
boost::nonassignable (), lval_ (p.lval_) {}
template <class E>
BOOST_UBLAS_INLINE
closure_type &operator= (const E& e) {
lval_.assign (e);
return lval_;
}
template <class E>
BOOST_UBLAS_INLINE
closure_type &operator+= (const E& e) {
lval_.plus_assign (e);
return lval_;
}
template <class E>
BOOST_UBLAS_INLINE
closure_type &operator-= (const E& e) {
lval_.minus_assign (e);
return lval_;
}
private:
closure_type lval_;
};
// Improve syntax of effcient assignment where no aliases of LHS appear on the RHS
// noalias(lhs) = rhs_expression
template <class C>
BOOST_UBLAS_INLINE
noalias_proxy<C> noalias (C& lvalue) {
return noalias_proxy<C> (lvalue);
}
template <class C>
BOOST_UBLAS_INLINE
noalias_proxy<const C> noalias (const C& lvalue) {
return noalias_proxy<const C> (lvalue);
}
}}}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -