V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
owenliang
V2EX  ›  C

if you learn c++11, we are not friend anymore.

  •  
  •   owenliang · 2017-09-13 09:22:53 +08:00 · 4802 次点击
    这是一个创建于 2388 天前的主题,其中的信息可能已经有所发展或是发生改变。

    请大家各抒己见。

    47 条回复    2017-09-27 22:29:34 +08:00
    ryanking8215
        1
    ryanking8215  
       2017-09-13 09:24:52 +08:00
    好几年不用 cpp 的问一下,梗在哪里?
    KaoN
        2
    KaoN  
       2017-09-13 09:30:53 +08:00
    vs2005 飘过。。。
    missdeer
        3
    missdeer  
       2017-09-13 09:31:26 +08:00
    再见!~
    arakashic
        4
    arakashic  
       2017-09-13 09:49:14 +08:00   ❤️ 9
    Who care? We WERE not friends.
    enenaaa
        5
    enenaaa  
       2017-09-13 09:52:04 +08:00
    随意,反正 c++11 以上的特性都看不懂。
    lrh3321
        6
    lrh3321  
       2017-09-13 09:56:57 +08:00
    再见!~
    睡不着的时候就翻翻 c++17
    PythonAnswer
        7
    PythonAnswer  
       2017-09-13 09:57:28 +08:00
    es6 啥时候能普及啊,不用转换成 es5 就能直接运行。
    121121121
        8
    121121121  
       2017-09-13 10:06:43 +08:00
    c++20 出来后怎么办?
    ashong
        9
    ashong  
       2017-09-13 10:09:37 +08:00
    c++11 很好用啊, 尤其是 lambda expression 非常方便
    we000
        10
    we000  
       2017-09-13 10:09:50 +08:00   ❤️ 1
    大家记得不要交那种认为别人都应该和自己一样想法的"朋友"
    chiu
        11
    chiu  
       2017-09-13 11:44:17 +08:00 via Android
    什么梗,友元函数?
    NullMan
        12
    NullMan  
       2017-09-13 13:00:26 +08:00
    @chiu 噗,友元函数!谁告诉我这又是那个英语术语的翻译?
    congeec
        13
    congeec  
       2017-09-13 13:05:29 +08:00
    @NullMan friend function 咋啦?
    glogo
        14
    glogo  
       2017-09-13 13:06:13 +08:00
    被戳中莫名笑点 233333333
    visionsmile
        15
    visionsmile  
       2017-09-13 13:06:23 +08:00
    @NullMan #12 友元 -> friend
    >A friend of a class is a function or class that is given permission to use the private and protected member names from the class.
    owenliang
        16
    owenliang  
    OP
       2017-09-13 13:07:48 +08:00
    if you think c++11 is good, we end the talk.
    msg7086
        17
    msg7086  
       2017-09-13 13:16:09 +08:00
    @owenliang s/friend/friends/

    @arakashic s/care/cares/
    owenliang
        18
    owenliang  
    OP
       2017-09-13 13:18:36 +08:00
    @msg7086 good job, sed is useful.
    northisland
        19
    northisland  
       2017-09-13 13:19:02 +08:00 via iPhone
    If you think c++11 sucks, go play C++99 without libboost.😜😜😜
    owenliang
        20
    owenliang  
    OP
       2017-09-13 13:19:16 +08:00
    @enenaaa c++11 brings us more pain than happiness.
    owenliang
        21
    owenliang  
    OP
       2017-09-13 13:21:28 +08:00
    @northisland no boost at all, c++03 means c with class and STL for me, which are really meaningful.
    pezy
        22
    pezy  
       2017-09-13 13:33:48 +08:00
    能先说说 C++11 带给你什么 pain 了么?
    AngelCriss
        23
    AngelCriss  
       2017-09-13 13:35:27 +08:00 via Android   ❤️ 2
    对,我现在都用的 C++17。
    owenliang
        24
    owenliang  
    OP
       2017-09-13 13:38:53 +08:00
    i don't know what i am doing when using c++11, this feeling is really bad for me.
    owenliang
        25
    owenliang  
    OP
       2017-09-13 13:39:18 +08:00
    @AngelCriss cool, man.
    meecle
        26
    meecle  
       2017-09-13 13:40:23 +08:00
    最近重拾 c++, 已经没有几年前那种恐惧感了,如 c++创始人说,c++是一门严肃的语言。它让你感到痛苦,恐惧,不是它自身的问题,只是把原始的东西给你呈现出来了而已。
    为了克服恐惧感甚至喜好问题, 你可以选择任何符合你口味的语言,但一定要明白你只是选择不去了解这些而已,不代表原始的东西不存在。
    owenliang
        27
    owenliang  
    OP
       2017-09-13 13:44:56 +08:00
    @meecle doesn't c++11 terrified you ?
    owenliang
        28
    owenliang  
    OP
       2017-09-13 13:47:02 +08:00
    I dived into c ++ 8 years ago, but I still can not persuade myself to learn c ++ 11.
    meecle
        29
    meecle  
       2017-09-13 13:49:11 +08:00
    @owenliang 恐惧,但是这个恐惧不是来自 c++,而是计算机本身( os, compiler.....),这么说可能你不相信
    seeker
        30
    seeker  
       2017-09-13 13:52:55 +08:00
    用 c++11 的特性几年了
    daimao
        31
    daimao  
       2017-09-13 13:55:39 +08:00 via iPhone
    c++17 都出了,竟然 11 都不用… 相比阁下还在用 XP 吧?

    PS:看楼上几位用英文尬聊真是尴尬无比
    owenliang
        32
    owenliang  
    OP
       2017-09-13 13:58:42 +08:00
    @daimao Is there any feature we have to use in c++11? and what if without c++11?
    meecle
        33
    meecle  
       2017-09-13 14:00:38 +08:00
    @owenliang 你这么问,问题就跑偏了,我们有必要用 c++么? 如果没有 c++会怎样?
    Athrob
        34
    Athrob  
       2017-09-13 14:03:49 +08:00
    来练习下英语阅读理解
    owenliang
        35
    owenliang  
    OP
       2017-09-13 14:03:56 +08:00
    @meecle no, what we discus is c++ iteself.
    daimao
        36
    daimao  
       2017-09-13 14:04:13 +08:00 via iPhone
    @owenliang 没有,毕竟都是图灵完全的,只不过差「几行」代码量而已。
    zmj1316
        37
    zmj1316  
       2017-09-13 14:11:17 +08:00
    C++ 17 才有的 if constexpr,比 C++ 11 的 enable_if 高到不知哪里去了,坐等支持 C++ 17
    svenFeng
        38
    svenFeng  
       2017-09-13 14:34:59 +08:00 via Android
    @owenliang
    0. 移动语义,大内存堆上的对象,没有移动语义以为着你要么到处深复制,要么到处跑指针,频繁的深复制性能不行,到处跑指针,没有智能指针析构会很麻烦,难以避免悬空指针,没有 std::optional 意味着你要养成每次使用指针判断的好习惯,不然无法避免空指针。
    1. auto,当然如果你喜欢每次把写一串模板信息来声明一个迭代器,并且喜欢每次看代码的时候认那一坨东西,我也无话可说:)
    2. foreach,解决下标索引不小心逻辑错误的情况
    3. override,虚函数没写对的情况

    。。。。。

    哇不想列了,再不想要讨论这种事情了,总结一下就是,如果你是写代码不会犯错的神,那么那些东西对你都没用,可惜不是,所以 C++的进化在于,让你用更少的代码,在不牺牲性能的情况下,写出更容易正确的程序。
    svenFeng
        39
    svenFeng  
       2017-09-13 14:37:52 +08:00 via Android
    @zmj1316 不用等啊,可以直接用了 constexpr if 了,主流编译器都支持了,我已经用 constexpr if 替换掉之前用 enable_if 写的一坨坨的代码了
    liuminghao233
        40
    liuminghao233  
       2017-09-13 14:38:48 +08:00 via iPhone
    auto+ template 简直是 666
    NullMan
        41
    NullMan  
       2017-09-13 15:23:39 +08:00
    @congeec @visionsmile 果真还是英文术语好懂,一眼就看出是个啥了。
    owenliang
        42
    owenliang  
    OP
       2017-09-13 16:12:53 +08:00 via Android
    zmj1316
        43
    zmj1316  
       2017-09-13 20:39:17 +08:00
    @svenFeng 貌似要 VS 2017 才有,我们这还没几个人装了 17 的...要是用了别人就没法编译了...
    lrxiao
        44
    lrxiao  
       2017-09-13 23:23:53 +08:00
    variadic template parameter
    unordered_
    shihira
        45
    shihira  
       2017-09-14 10:06:45 +08:00
    if C++11 sucks, all C++ standards suck.

    但是我能理解你,可能就是一种玩游戏加了太多 mod 然后觉得玩起来不原汁原味赢了心情也不好的感觉。
    owenliang
        46
    owenliang  
    OP
       2017-09-14 11:05:04 +08:00
    @daimao 酷。
    @zmj1316 酷。
    @shihira 是这种 suck 的感觉。
    yorTX9t
        47
    yorTX9t  
       2017-09-27 22:29:34 +08:00
    But I have been using c++17 for quite a long time......
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   981 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:26 · PVG 04:26 · LAX 13:26 · JFK 16:26
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.