@@ -290,6 +290,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“
290
290
<source lang="cpp">
291
291
#include <iostream>
292
292
#include <boost/format.hpp>
293
+
293
294
using std::cout;
294
295
using boost::format;
295
296
@@ -347,6 +348,7 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“
347
348
代码示例——基于正则式进行匹配和替换
348
349
<source lang="cpp">
349
350
#include <boost/regex.hpp>
351
+
350
352
using std::string;
351
353
using namespace boost;
352
354
@@ -384,6 +386,7 @@ Home:[https://github.com/google/re2]
384
386
代码示例——基于正则式进行匹配
385
387
<source lang="cpp">
386
388
#include <re2/re2.h>
389
+
387
390
int i;
388
391
string s;
389
392
assert(RE2::FullMatch("test:1234", "(\\w+):(\\d+)", &s, &i));
@@ -719,11 +722,13 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,用来辅助
719
722
#include <iostream>
720
723
#include <boost/function.hpp>
721
724
722
- boost::function<int(const char*)> f = std::atoi;
723
- std::cout << f("42") << '\n';
725
+ using namespace std;
726
+
727
+ boost::function<int(const char*)> f = atoi;
728
+ cout << f("42") << '\n';
724
729
725
- f = std:: strlen;
726
- std:: cout << f("42") << '\n';
730
+ f = strlen;
731
+ cout << f("42") << '\n';
727
732
</source>
728
733
729
734
<h4>Boost.Lambda</h4>
@@ -741,10 +746,11 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,提供了“
741
746
#include <iostream>
742
747
#include <boost/lambda/lambda.hpp>
743
748
744
- std::vector<int> v;
749
+ using namespace std;
750
+
751
+ vector<int> v;
745
752
// 此处填充 v
746
- std::for_each(v.begin(), v.end(),
747
- std::cout << boost::lambda::_1 << "\n");
753
+ for_each(v.begin(), v.end(), cout << boost::lambda::_1 << "\n");
748
754
</source>
749
755
750
756
== 3.4 元编程(Metaprogramming) ==
@@ -1316,7 +1322,8 @@ Links:[https://en.wikipedia.org/wiki/Getopt Wikipedia]
1316
1322
#include <stdio.h> /* for printf */
1317
1323
#include <stdlib.h> /* for exit */
1318
1324
#include <unistd.h> /* for getopt */
1319
- int main(int argc, char** argv)
1325
+
1326
+ int main(int argc, char* argv[])
1320
1327
{
1321
1328
int digit_optind = 0;
1322
1329
int aopt = 0, bopt = 0;
@@ -1410,7 +1417,7 @@ Links:[https://en.wikipedia.org/wiki/Pcap Wikipedia]
1410
1417
#include <stdio.h>
1411
1418
#include <pcap.h>
1412
1419
1413
- int main(int argc, char* argv[] )
1420
+ int main()
1414
1421
{
1415
1422
pcap_t* handle; /* Session handle */
1416
1423
char* dev; /* The device to sniff on */
@@ -1680,7 +1687,7 @@ ZeroMQ 是一个轻量级、跨平台的开源库,提供了高性能、异步
1680
1687
<source lang="cpp">
1681
1688
#include <zhelpers.hpp>
1682
1689
1683
- int main(int argc, char* argv[] )
1690
+ int main()
1684
1691
{
1685
1692
zmq::context_t context(1);
1686
1693
@@ -1772,7 +1779,6 @@ Links:[https://en.wikipedia.org/wiki/Libevent Wikipedia] [https://zh.wikipedia
1772
1779
#include <stdio.h>
1773
1780
#include <stdlib.h>
1774
1781
#include <unistd.h>
1775
-
1776
1782
#include <event.h>
1777
1783
#include <evhttp.h>
1778
1784
@@ -1785,7 +1791,7 @@ void generic_request_handler(struct evhttp_request* req, void* arg)
1785
1791
evbuffer_free(return_buffer);
1786
1792
}
1787
1793
1788
- int main(int argc, char** argv )
1794
+ int main()
1789
1795
{
1790
1796
short http_port = 8080;
1791
1797
char* http_addr = "127.0.0.1";
@@ -2319,7 +2325,7 @@ MongoDB 前面已经介绍过。这是其官方提供的 API。
2319
2325
#include <bson.h>
2320
2326
#include <mongoc.h>
2321
2327
2322
- int main(int argc, char* argv[] )
2328
+ int main()
2323
2329
{
2324
2330
mongoc_init();
2325
2331
@@ -3415,7 +3421,9 @@ Boost 前面已经介绍过。这是 Boost 的其中一个子库,实现了 BLA
3415
3421
#include <boost/numeric/ublas/matrix.hpp>
3416
3422
#include <boost/numeric/ublas/io.hpp>
3417
3423
3424
+ using namespace std;
3418
3425
using namespace boost::numeric::ublas;
3426
+
3419
3427
vector<double> v(2);
3420
3428
v(0) = 1; v(1) = 2;
3421
3429
@@ -3424,7 +3432,7 @@ m(0,0) = 0; m(0,1) = 1;
3424
3432
m(1,0) = 2; m(1,1) = 3;
3425
3433
3426
3434
vector<double> v2 = prod(m, v);
3427
- std:: cout << v2 << std:: endl;
3435
+ cout << v2 << endl;
3428
3436
</source>
3429
3437
3430
3438
<h4>Blitz++</h4>
0 commit comments