zoukankan      html  css  js  c++  java
  • gcc4.9.1新特性

    C family
    
    Support for colorizing diagnostics emitted by GCC has been added. The -fdiagnostics-color=auto will enable it when outputting to terminals, -fdiagnostics-color=always unconditionally. The GCC_COLORS environment variable can be used to customize the colors or disable coloring. If GCC_COLORS variable is present in the environment, the default is -fdiagnostics-color=auto, otherwise -fdiagnostics-color=never.
    Sample diagnostics output:
        $ g++ -fdiagnostics-color=always -S -Wall test.C
        test.C: In function ‘int foo()’:
        test.C:1:14: warning: no return statement in function returning non-void [-Wreturn-type]
         int foo () { }
                      ^
        test.C:2:46: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) instantiating ‘struct X<100>’
         template <int N> struct X { static const int value = X<N-1>::value; }; template struct X<1000>;
                                                      ^
        test.C:2:46:   recursively required fromconst int X<999>::value’
        test.C:2:46:   required fromconst int X<1000>::value’
        test.C:2:88:   required from here
    
        test.C:2:46: error: incomplete type ‘X<100>’ used in nested name specifier
        
    With the new #pragma GCC ivdep, the user can assert that there are no loop-carried dependencies which would prevent concurrent execution of consecutive iterations using SIMD (single instruction multiple data) instructions.
    Support for Cilk Plus has been added and can be enabled with the -fcilkplus option. Cilk Plus is an extension to the C and C++ languages to support data and task parallelism. The present implementation follows ABI version 1.2; all features but _Cilk_for have been implemented.
    C
    
    ISO C11 atomics (the _Atomic type specifier and qualifier and the <stdatomic.h> header) are now supported.
    ISO C11 generic selections (_Generic keyword) are now supported.
    ISO C11 thread-local storage (_Thread_local, similar to GNU C __thread) is now supported.
    ISO C11 support is now at a similar level of completeness to ISO C99 support: substantially complete modulo bugs, extended identifiers (supported except for corner cases when -fextended-identifiers is used), floating-point issues (mainly but not entirely relating to optional C99 features from Annexes F and G) and the optional Annexes K (Bounds-checking interfaces) and L (Analyzability).
    A new C extension __auto_type provides a subset of the functionality of C++11 auto in GNU C.
    C++
    
    The G++ implementation of C++1y return type deduction for normal functions has been updated to conform to N3638, the proposal accepted into the working paper. Most notably, it adds decltype(auto) for getting decltype semantics rather than the template argument deduction semantics of plain auto:
    int& f();
             auto  i1 = f(); // int
    decltype(auto) i2 = f(); // int&
    G++ supports C++1y lambda capture initializers:
    [x = 42]{ ... };
    Actually, they have been accepted since GCC 4.5, but now the compiler doesn't warn about them with -std=c++1y, and supports parenthesized and brace-enclosed initializers as well.
    G++ supports C++1y variable length arrays. G++ has supported GNU/C99-style VLAs for a long time, but now additionally supports initializers and lambda capture by reference. In C++1y mode G++ will complain about VLA uses that are not permitted by the draft standard, such as forming a pointer to VLA type or applying sizeof to a VLA variable. Note that it now appears that VLAs will not be part of C++14, but will be part of a separate document and then perhaps C++17.
    void f(int n) {
      int a[n] = { 1, 2, 3 }; // throws std::bad_array_length if n < 3
      [&a]{ for (int i : a) { cout << i << endl; } }();
      &a; // error, taking address of VLA
    }
    G++ supports the C++1y [[deprecated]] attribute modulo bugs in the underlying [[gnu::deprecated]] attribute. Classes and functions can be marked deprecated and a diagnostic message added:
    class A;
    int bar(int n);
    #if __cplusplus > 201103
    class [[deprecated("A is deprecated in C++14; Use B instead")]] A;
    [[deprecated("bar is unsafe; use foo() instead")]]
    int bar(int n);
    
    int foo(int n);
    class B;
    #endif
    A aa; // warning: 'A' is deprecated : A is deprecated in C++14; Use B instead
    int j = bar(2); // warning: 'int bar(int)' is deprecated : bar is unsafe; use foo() instead
    G++ supports C++1y digit separators. Long numeric literals can be subdivided with a single quote ' to enhance readability:
    int i = 1048576;
    int j = 1'048'576;
    int k = 0x10'0000;
    int m = 0'004'000'000;
    int n = 0b0001'0000'0000'0000'0000'0000;
    
    double x = 1.602'176'565e-19;
    double y = 1.602'176'565e-1'9;
    G++ supports C++1y generic (polymorphic) lambdas.
    // a functional object that will increment any type
    auto incr = [](auto x) { return x++; };
    As a GNU extension, G++ supports explicit template parameter syntax for generic lambdas. This can be combined in the expected way with the standard auto syntax.
    // a functional object that will add two like-type objects
    auto add = [] <typename T> (T a, T b) { return a + b; };
    G++ supports unconstrained generic functions as specified by §4.1.2 and §5.1.1 of N3889: Concepts Lite Specification. Briefly, auto may be used as a type-specifier in a parameter declaration of any function declarator in order to introduce an implicit function template parameter, akin to generic lambdas.
    // the following two function declarations are equivalent
    auto incr(auto x) { return x++; }
    template <typename T>
    auto incr(T x) { return x++; }
    Runtime Library (libstdc++)
    
    Improved support for C++11, including:
    support for <regex>;
    The associative containers in <map> and <set> and the unordered associative containers in <unordered_map> and <unordered_set> meet the allocator-aware container requirements;
    Improved experimental support for the upcoming ISO C++ standard, C++14, including:
    fixing constexpr member functions without const;
    implementation of the std::exchange() utility function;
    addressing tuples by type;
    implemention of std::make_unique;
    implemention of std::shared_lock;
    making std::result_of SFINAE-friendly;
    adding operator() to integral_constant;
    adding user-defined literals for standard library types std::basic_string, std::chrono::duration, and std::complex;
    adding two range overloads to non-modifying sequence oprations std::equal and std::mismatch;
    adding IO manipulators for quoted strings;
    adding constexpr members to <utility>, <complex>, <chrono>, and some containers;
    adding compile-time std::integer_sequence;
    adding cleaner transformation traits;
    making <functional>s operator functors easier to use and more generic;
    An implementation of std::experimental::optional.
    An implementation of std::experimental::string_view.
    The non-standard function std::copy_exception has been deprecated and will be removed in a future version. std::make_exception_ptr should be used instead.
  • 相关阅读:
    Vue组件库elementUI 在el-row 或 el-col 上使用@click无效失效,
    js判断客户端是手机端还是PC端
    IOS上微信在输入框弹出键盘后,页面不恢复,下方有留白,有弹窗弹出时页面内容感应区域错位
    vue打包问题:Tip: built files are meant to be served over an HTTP server.
    在vue项目npm run build后,index.html中引入css和js 报MIME type问题
    Vue项目中如何使用less(添加less依赖)
    Mac 下永久路由的添加 & Mac 校园网连接教程
    JetBrains RubyMine 2019 for Mac(Ruby代码编辑器) 这些功能你用了几个?
    代码片段管理软件Snippetslab mac版软件测评
    十分钟玩转 XMind 中的多种思维结构
  • 原文地址:https://www.cnblogs.com/huashiyiqike/p/3927399.html
Copyright © 2011-2022 走看看