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

📄 00-1.cpp

📁 effective stl 源代码 code
💻 CPP
字号:
//
// Examples from Introduction
//

#include <iostream>
#include <vector>

#include "ESTLUtil.h"


template<typename C>
bool lastGreaterThanFirst(const C& container)
{
	if (container.empty()) return false;
	typename C::const_iterator begin(container.begin());
	typename C::const_iterator end(container.end());
	return *--end > *begin;
}

int main()
{
	using namespace std;
	using namespace ESTLUtils;

	const int ints[] = { -30, 102, 55, -19, 0, 222, -3000, 4000, 8, -2 };
	const size_t nints = sizeof ints / sizeof (int);

	vector<int> v(ints, ints + nints);
	printContainer("v", v);

	cout << "lastGreaterThanFirst(v) returns: " <<
				lastGreaterThanFirst(v) << endl;

	v[0] = 5;

	cout << "lastGreaterThanFirst(v) returns: " <<
				lastGreaterThanFirst(v) << endl;

	return 0;
}

⌨️ 快捷键说明

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