官术网_书友最值得收藏!

Self-test questions

For multiple choice questions, choose all the options that apply:

  1. What are the advantages of using boost::swap over std::swap?

    a. There is no real advantage

    b. boost::swap invokes swap overloads supplied with the passed type, if any

    c. boost::swap is faster than std::swap

    d. boost::swap does not throw exceptions

  2. Can you apply a visitor to multiple variant arguments in a single call? (Hint: you may want to look up the online documentation)

    a. Yes. A visitor can only be applied to one or two variant arguments

    b. Yes. A visitor can be applied to one or more arguments

    c. No. The member operators take only one variant argument

    d. None of the above

  3. Is the following a valid compile-time assert?

    BOOST_STATIC_ASSERT(x == 0); // x is some variable

    a. Yes, provided x is of an integral type

    b. Yes, provided x is declared as a const static numeric variable

    c. No, x is a variable, and its value cannot be known at compile time

    d. Only expressions involving sizeof are valid in a BOOST_STATIC_ASSERT

  4. What do we mean when we say that a type X is a POD type?

    a. X does not have a user-defined constructor or destructor

    b. X can be copied by copying its memory layout bit-wise

    c. X does not have a user-defined copy constructor or copy assignment operator

    d. All of the above

  5. What is the type and value stored in a default-constructed object of type boost::variant<std::string, double>?

    a. The type is const char* and value is NULL

    b. The type is double and value is 0.0

    c. The type is std::string and value is the default constructed std::string

    d. The type is boost::optional<double> and value is empty

  6. Check the reference on Boost.Optional in the online documentation for the latest Boost libraries. What happens if you call the get and get_ptr methods on an empty optional object?

    a. Both throw the boost::empty_optional exception

    b. get throws an exception, while get_ptr returns a null pointer

    c. get asserts, while get_ptr returns a null pointer

    d. Both get and get_ptr assert

主站蜘蛛池模板: 偏关县| 岑溪市| 垦利县| 贵港市| 许昌县| 陇西县| 黑河市| 云龙县| 咸丰县| 马关县| 确山县| 富平县| 襄城县| 运城市| 樟树市| 玉龙| 玉环县| 武义县| 弥渡县| 兴城市| 镇原县| 阿拉善左旗| 丹寨县| 化州市| 星座| 鄢陵县| 汉沽区| 京山县| 鹤岗市| 德格县| 孟州市| 梓潼县| 保定市| 射洪县| 绥德县| 台州市| 漯河市| 阳江市| 香港 | 鞍山市| 白水县|