?? foreach2.h
字號:
// foreach2.h: Implementing FOR_EACH without using typeof
class IterBase {
public:
virtual bool next()=0;
};
template <class V, class C>
class Iter: public IterBase {
protected:
V& _ref;
C::iterator _ci, _ci_end;
public:
Iter(V& ref, C& con)
: _ref(ref), _ci_end(con.end()), _ci(con.begin())
{ }
bool next ()
{
if (_ci == _ci_end) return false;
_ref = *_ci;
_ci++;
return true;
}
};
template <class C>
IterBase *_make_iter(C::value_type& ref, C& con)
{
return new Iter<C::value_type,C> (ref,con);
}
#define FOR_EACH(i,li) \
for(std::auto_ptr<IterBase> it(_make_iter(i,(li))); \
it->next();)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -