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

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

主站蜘蛛池模板: 治多县| 凌云县| 宜昌市| 涡阳县| 中阳县| 云浮市| 格尔木市| 和政县| 定襄县| 长汀县| 长岭县| 文水县| 亚东县| 亳州市| 绥棱县| 临汾市| 苍梧县| 云霄县| 赞皇县| 辰溪县| 黑水县| 广丰县| 伊川县| 博客| 南雄市| 内乡县| 故城县| 万山特区| 获嘉县| 石屏县| 永和县| 怀安县| 郎溪县| 杭州市| 炎陵县| 砀山县| 进贤县| 陆丰市| 尖扎县| 永和县| 民丰县|