<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"><channel><title><![CDATA[labud的专栏]]></title><description><![CDATA[]]></description><link>https://blog.youkuaiyun.com/labud</link><language>zh-cn</language><generator>https://blog.youkuaiyun.com/</generator><copyright><![CDATA[Copyright &copy; labud]]></copyright><item><title><![CDATA[《Effective Modern C++》Item 11: Prefer deleted functions to private undefined ones.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80972545</link><guid>https://blog.youkuaiyun.com/labud/article/details/80972545</guid><author>labud</author><pubDate>Mon, 09 Jul 2018 15:53:15 +0800</pubDate><description><![CDATA[引子

当我们不想向用户提供某个函数功能时，我们只需要不实现它就可以了。但是在C++中，有一些函数会被默认实现，例如类的复制构造函数(copy constructor)和赋值函数(copy assignment operator)。这时C++98中的方法就是设置其属性为私有函数，通过访问权限来限制用户的实用。

正文

但是上面的方法并不总是成立，例如友元函数(friend function)仍然...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 10: Prefer scoped enums to unscoped enums.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80968007</link><guid>https://blog.youkuaiyun.com/labud/article/details/80968007</guid><author>labud</author><pubDate>Mon, 09 Jul 2018 11:48:46 +0800</pubDate><description><![CDATA[引子

枚举是C中一个常见的基本类型，一般来说，我们声明一个变量，它的作用域仅存在于它外层花括号包围的范围内，但是这个限制对于枚举(准确说C++98版本的枚举)并不成立：



enum Color { black, white, red };   // black, white, red are in same scope as Color
auto white = false;        ...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 9: Prefer alias declarations to typedefs.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80826189</link><guid>https://blog.youkuaiyun.com/labud/article/details/80826189</guid><author>labud</author><pubDate>Wed, 27 Jun 2018 14:54:06 +0800</pubDate><description><![CDATA[引子

C++11中引入的std::unique_ptr智能指针是个好用的东西，在我们使用unique_ptr的时候往往会写出这样的类型std::uniqeu_ptr&amp;amp;lt;std::unordered_map&amp;amp;lt;std::string,std::string&amp;amp;gt;&amp;amp;gt;,看上去很臃肿，因此大多数的时候我们会选择使用typedef进行类型的重定义，简化类型名称。可是在C++11中引入了一个...]]></description><category></category></item><item><title><![CDATA[《Effective Morden C++》Item 8: Prefer nullptr to 0 and NULL.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80792037</link><guid>https://blog.youkuaiyun.com/labud/article/details/80792037</guid><author>labud</author><pubDate>Sun, 24 Jun 2018 16:13:52 +0800</pubDate><description><![CDATA[引子

这一条目就比较简单了，就是宣传用nullptr来指代空指针，而不是之前的0或者NULL。

正文

在老式C++中，显然0是int类型，而NULL也是一个整数类型(int或者long)。总的来说，这两个常用来表示空指针的符号并不是真正的指针类型。这样，当我们在进行函数重载时会发生麻烦，例如：



void f(int);        // three overloads of f
vo...]]></description><category></category></item><item><title><![CDATA[《Effective Morden C++》Item 7: Distinguish between () and {} when creating objects]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80764079</link><guid>https://blog.youkuaiyun.com/labud/article/details/80764079</guid><author>labud</author><pubDate>Fri, 22 Jun 2018 10:44:05 +0800</pubDate><description><![CDATA[引子

从本Item开始，我们就进入了第二个章节，本章节，S.M.通过对比C++的新老feature来鼓励大家使用new features. 本Item先从对象初始化开始。

正文



1.基础

C++11中引入了{}初始化，这样使得我们的初始化变得很丰富，我们可以用{}, () 和 = 三种初始化方法:

int x(0);
int y = 0;
int z{0};
int c = {0};...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 6: Use the explicitly typed initializer idiom when auto deduces undesired]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80655930</link><guid>https://blog.youkuaiyun.com/labud/article/details/80655930</guid><author>labud</author><pubDate>Mon, 11 Jun 2018 18:06:51 +0800</pubDate><description><![CDATA[引子

之前Item 5介绍了auto关键字的优点，当然在Item 2我们看到了auto的一些不足，比如由于auto也是在用模板类型做推导，所以某些情况下会丢掉CV修饰符。但这个缺点似乎没有那么有说服力，毕竟这是模板类型推导的锅。本文我们继续探讨auto本身的缺点。

正文

先看一段代码



std::vector&amp;lt;bool&amp;gt; features(const Widget&amp;amp; ...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 5: Prefer auto to explicit type declarations.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80627184</link><guid>https://blog.youkuaiyun.com/labud/article/details/80627184</guid><author>labud</author><pubDate>Fri, 08 Jun 2018 19:20:57 +0800</pubDate><description><![CDATA[引子

这篇文章主要是branding auto这个关键字。和Item 2不同的是，本文主要是夸赞auto的优点，而Item 2则是简单的介绍。当然auto也有自己的问题，我们会在Item 2和Item 6中谈及它的问题。

正文



1.帮助检查初始化以及减少代码复杂度

这条很容易理解意思，不细说。直接看例子

int x1;         // potentially uninitial...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 4: Know how to view deduced types.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80573505</link><guid>https://blog.youkuaiyun.com/labud/article/details/80573505</guid><author>labud</author><pubDate>Mon, 04 Jun 2018 21:36:37 +0800</pubDate><description><![CDATA[引子

本条目就相当轻松了，主要是S.M.老爷子教大家如何查看类型，毕竟之前3节讲了这么多，对于C++1x的新手来说上手还是要花一段时间的，所以从下面3个角度介绍如何查看类型：


IDE
编译器时诊断
运行时输出


正文

正文中，我们需要获得下面两个变量的类型：



const int theAnswer = 42; 

auto x = theAnswer;
auto y = &amp;amp;...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 3: Understand decltype.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80560203</link><guid>https://blog.youkuaiyun.com/labud/article/details/80560203</guid><author>labud</author><pubDate>Sun, 03 Jun 2018 21:02:29 +0800</pubDate><description><![CDATA[引子

decltype是C++中的一个老特性了，绝大多数情况它会让你获得你期望的类型。当然，凡事都有特例，我们需要稍微注意一下，除了避免踩坑以外，也能帮助我们进一步了解类型推导。

正文



1.普通情形

我们先预热一下，看看decltype确实是大部分时候是符合预期的：

const int i = 0;                // decltype(i) is const int...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 2: Understand auto type deduction.]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80556636</link><guid>https://blog.youkuaiyun.com/labud/article/details/80556636</guid><author>labud</author><pubDate>Sun, 03 Jun 2018 14:54:26 +0800</pubDate><description><![CDATA[正文

1.普通情形

在c++11中，引入了auto关键字，关于auto关键字的推导，绝大多数和上一个Item的模板推导是一样的。例如：

auto x = 27;                // case 3 (x is not reference)
const auto cx = x;          // case 3 (cx isn't either)
const auto&amp;amp;amp...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》Item 1: Understand template type deduction]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80535802</link><guid>https://blog.youkuaiyun.com/labud/article/details/80535802</guid><author>labud</author><pubDate>Fri, 01 Jun 2018 18:36:47 +0800</pubDate><description><![CDATA[引子

老爷子上来第一大章(Item 1-4)就讨论了类型推导，依次介绍了:


模版类型推导
auto类型推导
decltype关键字
获取变量类型的正确姿势


当然了，从最简单的auto关键字入手，确实是方便老c++用户熟悉c++11/14的快速方法。

本文就先介绍模板类型推倒吧。

正文

先看一段代码



template&amp;amp;lt;typename T&amp;amp;gt; 
void f(Para...]]></description><category></category></item><item><title><![CDATA[《Effective Modern C++》读书笔记]]></title><link>https://blog.youkuaiyun.com/labud/article/details/80530166</link><guid>https://blog.youkuaiyun.com/labud/article/details/80530166</guid><author>labud</author><pubDate>Thu, 31 May 2018 21:05:47 +0800</pubDate><description><![CDATA[最近开始从Java技术栈换回C++技术栈，于是找到了S. Meyers老爷子的《Effective Modern C++》出来重新学习C++。说实话，当年读研时读过他的经典作品《Effective C++》和《More Effective C++》，受益匪浅。这次开了个新坑，打算做个简单的读书笔记，每条笔记都和原书对应，但又有些不同：


只做概要性笔记，不面面俱到，毕竟能看到《Effective...]]></description><category></category></item><item><title><![CDATA[Cloudera Manager Java Version]]></title><link>https://blog.youkuaiyun.com/labud/article/details/53739863</link><guid>https://blog.youkuaiyun.com/labud/article/details/53739863</guid><author>labud</author><pubDate>Mon, 19 Dec 2016 14:48:50 +0800</pubDate><description><![CDATA[Cloudera Manager use /usr/lib/cmf/service/common/cloudera-config.sh to detect java version. The prefer order is JAVA 7 > JAVA 8 > JAVA 6 > OPENJAVA. 
To override default JAVA_HOME setting, should set J]]></description><category></category></item><item><title><![CDATA[Hadoop权威指南读书笔记(5) - MapReducer工作过程]]></title><link>https://blog.youkuaiyun.com/labud/article/details/52626060</link><guid>https://blog.youkuaiyun.com/labud/article/details/52626060</guid><author>labud</author><pubDate>Thu, 22 Sep 2016 20:54:14 +0800</pubDate><description><![CDATA[本文对应原书中第七章。其中的知识对于进一步调优MapReduce非常重要。我们先介绍MapReduce作业的运行过程，再介绍它的容错机制，然后会介绍其中的Shffle和Sort过程。]]></description><category></category></item><item><title><![CDATA[Hadoop权威指南读书笔记(3) - Hadoop I/O]]></title><link>https://blog.youkuaiyun.com/labud/article/details/52600505</link><guid>https://blog.youkuaiyun.com/labud/article/details/52600505</guid><author>labud</author><pubDate>Wed, 21 Sep 2016 01:12:19 +0800</pubDate><description><![CDATA[hadoop I/O
Writable]]></description><category></category></item><item><title><![CDATA[Hadoop权威指南读书笔记(2) — Yarn简介及Capacity & Fair Scheduler]]></title><link>https://blog.youkuaiyun.com/labud/article/details/52043557</link><guid>https://blog.youkuaiyun.com/labud/article/details/52043557</guid><author>labud</author><pubDate>Wed, 27 Jul 2016 19:18:31 +0800</pubDate><description><![CDATA[Yarn简介Yarn(Yet Another Resource Negotiator)是hadoop2中引入的一个集群资源管理系统。]]></description><category></category></item><item><title><![CDATA[Hadoop权威指南读书笔记(1) － MapReduce和HDFS简介]]></title><link>https://blog.youkuaiyun.com/labud/article/details/51958371</link><guid>https://blog.youkuaiyun.com/labud/article/details/51958371</guid><author>labud</author><pubDate>Tue, 19 Jul 2016 18:36:44 +0800</pubDate><description><![CDATA[最近开始读<< Hadoop:the definitive guide>>，于是打算写点读书笔记，书电子版见网盘，密码v66s。]]></description><category></category></item><item><title><![CDATA[图算法]]></title><link>https://blog.youkuaiyun.com/labud/article/details/48180755</link><guid>https://blog.youkuaiyun.com/labud/article/details/48180755</guid><author>labud</author><pubDate>Wed, 02 Sep 2015 17:05:35 +0800</pubDate><description><![CDATA[其实以前也写过很多遍图上的算法了，最近要准备各大公司面试，就把模板都贴在这吧。具体的算法看给的各个连接或者去网上搜一下就可以了。图的表示图的表示主要有邻接矩阵和邻接链表两者方法，前者随机访问容易但空间太大，后者空间小但随机访问较慢而且需要动态分配内存。一般在实现一些常见算法代码时，还有一种方法来表示图，即链式前向星 。这种方法本质上还是邻接表方法，但不需要动态分配内存，只需要知道边的总数即可。int]]></description><category></category></item><item><title><![CDATA[临时变量，左值右值，右值引用及其作用]]></title><link>https://blog.youkuaiyun.com/labud/article/details/47175105</link><guid>https://blog.youkuaiyun.com/labud/article/details/47175105</guid><author>labud</author><pubDate>Fri, 31 Jul 2015 20:27:22 +0800</pubDate><description><![CDATA[C++11 新增了很多功能，其中一个叫做右值引用。为了搞清楚这个东西，参考了几篇网上的博客，于是便有此文：  首先我们需要搞清楚左值和右值之分。而为了区分左值和右值，我们先注意到C++中的临时变量:C++中的临时变量指的是那些由编译器根据需要在栈上产生的，没有名字的变量。 
1) 函数的返回值, 如:]]></description><category></category></item><item><title><![CDATA[二叉树的遍历]]></title><link>https://blog.youkuaiyun.com/labud/article/details/47094131</link><guid>https://blog.youkuaiyun.com/labud/article/details/47094131</guid><author>labud</author><pubDate>Mon, 27 Jul 2015 23:56:01 +0800</pubDate><description><![CDATA[二叉树的遍历主要有3种模式，前序，中序和后序。其递归版本，非常简单，大致如下：void Traversal(TreeNode* root){
    if(!root)
        return;
    // visit root (preorder)
    Traversal(root->left);
    // visit root (inorder)
    Traversal(ro]]></description><category></category></item></channel></rss>