由买买提看人间百态

topics

全部话题 - 话题: decltype
(共0页)
k***a
发帖数: 1199
1
我写了个死算的,lintcode pass了,复杂度mnlg(mn)
#include
#include
#include
using namespace std;
class Solution {
public:
/**
* @param heights: a matrix of integers
* @return: an integer
*/
int trapRainWater(const vector> &heights) {
int m = heights.size();
if (m<3) return 0;
int n = heights[0].size();
if (n<3) return 0;

typedef pair P;

auto cmp = [&heights](const P& left, co... 阅读全帖
e****d
发帖数: 895
2
来自主题: Programming版 - C++0x
Except nameof(), there are equivalent items for the ones you
suggested. Any obvious advantage to add them?
%if-%else => template partial/explicit specialization + SFINAE
typeof() => template partial/explicit specialization + auto
+ decltype + suffix function return syntax
variant type => boost::any, template type parameter.
It seems to me those items you suggested are cosmetic.

like
(
r*****3
发帖数: 143
3
中文名: 新C++标准:C++0x 概述
原名: Overview of the New C++ : C++0x
作者: Scott Meyers
图书分类: 软件
资源格式: PDF
版本: 英文文字版
出版社: Artima
书号: 978-0-596-80197-6
发行时间: 2011年
地区: 美国
语言: 英文
简介:
内容介绍:
Specification of the next version of C++ (“C++0x”) is nearing completion,
and many compilers (e.g., Visual C++ and Gnu C++) already offer several
features from the revised language. And such features! auto-declared
variables reduce typing drudgery and syntactic noise; Unicode and threading
support address important functional... 阅读全帖
k***s
发帖数: 277
4
最近看了BS的TCPL 4th,觉得新特性加得太贴心(个人经验)
- auto, decltype, declval, meta programming/template的利器
- lambda,非常爽的特性
- rvalue reference &&, temporary object 的终极优化
- varidic, 可变长template参数列表, meta/template 利器
- {} 初始化列表,刚接触时觉得很变态,不过习惯了觉得很强大
很期望14、17的增强会 带来更多惊喜

part
b*******s
发帖数: 5216
5
来自主题: Programming版 - 无意争吵,不过介绍下
再讲泛型,generic,java的简直弱爆了
比如这样一个c++函数
template
auto f(const T1& t1,const T2& t2) -> decltype(t1 + t2)
{
return (t1 + t2);
}
直接解决了溢出问题,比如两个大的int,都是接近int上限的,相加肯定溢出,但这样
写就不会出问题,而且都是编译期决定,运行起来不要太快
o******0
发帖数: 105
6
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
It is very confusing and error-prone.Even Java does not have those.
f******y
发帖数: 2971
7
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
auto我认为应该尽量只用于局部变量,就是前后都扩起来一目了然地知道是什么类型的
时候。它的一个用处就是省了一些typing,尤其在namespace层数比较多,或者涉及
iterator的时候。
b*******s
发帖数: 5216
8
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
我的建议是,去学java或者c#,挺好的
f******y
发帖数: 2971
9
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
C#里有var
o******0
发帖数: 105
10
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
It is very confusing and error-prone.Even Java does not have those.
f******y
发帖数: 2971
11
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
auto我认为应该尽量只用于局部变量,就是前后都扩起来一目了然地知道是什么类型的
时候。它的一个用处就是省了一些typing,尤其在namespace层数比较多,或者涉及
iterator的时候。
b*******s
发帖数: 5216
12
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
我的建议是,去学java或者c#,挺好的
f******y
发帖数: 2971
13
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
C#里有var
d****i
发帖数: 4809
14
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
C++11's auto is fucking ugly IMHO. Static typed language should stick to its
static typed style. Java in this case stick to its static typed style
without any pollution.
N******K
发帖数: 10202
15
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
写template 一个类里面一大堆 typedef 看一会就晕了
用template <>套<>
auto一上 代码清爽
能用auto 我就用auto

its
N******K
发帖数: 10202
16
来自主题: Programming版 - Why C++11 introduce "decltype" and "auto"?
将来当全堆程序员 更好
k**********g
发帖数: 989
17
来自主题: Programming版 - type inferience 好处是什么

inference
所以才有 decltype 。因为写 meta programming 的大牛们忿怒了。
k**********g
发帖数: 989
(共0页)