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

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

主站蜘蛛池模板: 北海市| 托克托县| 论坛| 云阳县| 旅游| 大邑县| 新田县| 瓦房店市| 潞城市| 宁晋县| 满城县| 哈密市| 岑溪市| 南皮县| 永丰县| 鸡西市| 布尔津县| 德格县| 巨野县| 台南市| 田阳县| 晋城| 基隆市| 海城市| 四川省| 石棉县| 石河子市| 当涂县| 剑阁县| 和顺县| 舒城县| 鹤峰县| 遂溪县| 屏南县| 濮阳县| 阳东县| 阿克陶县| 海安县| 金门县| 靖安县| 丰台区|