小编Pre*_*Tiw的帖子

在C++中使用具有不同数量的参数的嵌套宏

以下代码在g ++ -std = c ++ 11编译器的编译中失败.

    # include<iostream>
    # include<vector>

    using namespace std;


    # define stlf(x)        x.begin(), x.end()
    # define repf(it, a, b) for(auto it = a ; it != b ; ++it)


    /*
    // Also, following alternative fails

    # define repf(it, a, b) for(auto it = a ; it != b ; ++it)
    # define stlf(x)        x.begin(), x.end()

    */



    typedef vector<int > vi;

    # define pd(x)  printf("%d", x);

    int main(void){

        vi arr(10, -1);

        repf(arr, stlf(arr))
            pd(arr[i]);


        return 0; …
Run Code Online (Sandbox Code Playgroud)

c++ macros c-preprocessor c++11

0
推荐指数
1
解决办法
374
查看次数

标签 统计

c++ ×1

c++11 ×1

c-preprocessor ×1

macros ×1