Ambiguous injected class name is not an error

后端 未结 2 1293
甜味超标
甜味超标 2021-01-01 15:30

What I read in the C++ standard about injected class names contradicts (as I see it) with the behavior of a sample program I will present shortly. Here\'s what I read:

2条回答
  •  甜味超标
    2021-01-01 15:45

    No, you are not missing anything, and your compiler seems to behave buggy. You can see how gcc handles it here: http://ideone.com/MI9gz

    Its error message is:

    prog.cpp:4:4: error: reference to 'vector' is ambiguous
    /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_vector.h:171:5: error: candidates are: class std::vector std::vector::vector
    /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/../../../../include/c++/4.5.1/bits/stl_vector.h:171:5: error:                 class std::vector std::vector::vector
    

提交回复
热议问题