Unit test that a class is non copyable, and other compile-time properties

前端 未结 3 1287
南旧
南旧 2020-12-03 16:56

Is there a way to test compile-time errors, but without actually generating the error? For example, if I create a class which is non-copyable, I\'d like to test the fact tha

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 17:51

    BTW the only build system I know that allows such test out-of-the-box is Boost.Build:

    Check here" http://beta.boost.org/boost-build2/doc/html/bbv2/builtins/testing.html

    For example,

    # in your Jamfile
    compile-fail crappy.cpp ;
    

    .

    int main()
    {
      my crappy cpp file
    }
    

    For more examples just grep -R compile-fail in your BOOST_TOP_DIR\libs directory.

提交回复
热议问题