<pre> //====================== start of sample.cpp ========================== #include <type_traits > class A { public: A(int in = 5); }; int main() { std::is_pointer<A> is_ptr; return 0; } //====================== end of sample.cpp ========================== </pre> Как может использоваться объявление переменной is_ptr?
<pre> //====================== start of sample.cpp ========================== #include <string> #include <type_traits> struct my_string { std::string s; my_string(const std::string& s); }; int main(int argc, char* argv[]) { is_copy_constructible<my_string>; return 0; } //====================== end of sample.cpp ========================== </pre> Каким образом можно проверить требование CopyConstructable посредством шаблона стандартной библиотеки is_copy_constructible для типа my_string из файла sample.cpp?
<pre> //====================== start of sample.cpp ========================== #include <type_traits> template <typename IT_1, typename IT_2, bool b> IT_2 copy_imp(IT_1 first, IT_1 last, IT_2 out, const std::integral_constant<bool, b>&) { while(first != last) { *out = *first; ++out; ++first; } return out; } template <typename T> T* copy_imp(const T* first, const T* last, T* out, const std::true_type&) { memmove(out, first, (last-first)*sizeof(T)); return out * (last-first); } template <typename I1, typename I2> inline I2 copy(I1 first, I1 last, I2 out) { typedef typename std::iterator_traits<I1>::value_type value_type; return copy_imp(first, last, out, std::has_trivial_assign<value_type>()); } class A {}; int main() { std::vector<A> vec1; std::vector<A> vec2; copy(vec1.begin(), vec1.end(), vec2.begin()); return 0; } //====================== end of sample.cpp ========================== </pre> Какие утверждения про то какая функция копирования copy_impl() будет использована верны?
<pre> //====================== start of sample.cpp ========================== #include <climits> #include <limits> #include <boost/static_assert.hpp> namespace name { BOOST_STATIC_ASSERT(std::numeric_limits<int>::digits == 32); } int main(int argc, char* argv[]) { return 0; } //====================== end of sample.cpp ========================== </pre> Что случится c программой из файла sample.cpp если в системе размер int больше 32 разрядов?
<pre> //====================== start of sample.cpp ========================== #include <type_traits> template <typename IT_1, typename IT_2, bool b> IT_2 copy_imp(IT_1 first, IT_1 last, IT_2 out, const std::integral_constant<bool, b>&) { while(first != last) { *out = *first; ++out; ++first; } return out; } template <typename T> T* copy_imp(const T* first, const T* last, T* out, const std::true_type&) { memmove(out, first, (last-first)*sizeof(T)); return out * (last-first); } template <typename I1, typename I2> inline I2 copy(I1 first, I1 last, I2 out) { typedef typename std::iterator_traits<I1>::value_type value_type; return copy_imp(first, last, out, std::has_trivial_assign<value_type>()); } class A {}; int main() { std::vector<short> arr1; std::vector<short> arr2; copy(arr1.begin(), arr1.end(), arr2.begin()); return 0; } //====================== end of sample.cpp ========================== </pre> Какие утверждения про используемую функцию копирования copy_impl() верны?
<pre> //====================== start of sample.cpp ========================== template <typename T> class multiplies: public binary_function<T,T,T> { public: T operator() (const T& x, const T& y) const { return x * y; } }; //====================== end of sample.cpp ========================== </pre> Какие утверждения про приведённый выше код функтора multiplies верны?
<pre> //====================== start of sample.cpp ========================== class ARef { public: ARef(A &a, int i) : _a(a), _ix(i) {} ARef& operator= (T t) { return *this;} operator T() {return _t;} operator A() {return _a;} A& getA() { return _a;} bool operator == (A& a) {return _a == a;} private: A& _a; int _ix; T _t; }; class A { friend class ARef; public: A() {} ARef operator[] (int ix) {return ARef(*this, ix);} operator ARef() {return ARef(*this, ix);} }; int main() { A a; int i, j; T t; t = a[j]; return 0; } //====================== end of sample.cpp ========================== </pre> Какие из методов классов ARef и A из файла sample.cpp оказываются задействованы при операции t=a[j]?
<pre>//====================== start of sample.cpp ========================== #include <vector> class ServiceOrganization; class Building { static char* m_city; const unsigned int m_high_size; std::vector<int> m_flats; unsigned int m_square; ServiceOrganization& m_organization; public: Building(); }; int main() { Building house; return 0; }//====================== end of sample.cpp ========================== </pre> Какие члены класса Building из файла sample.cpp обязательно должны быть инициализированы в списке инициализации?
<pre> //====================== start of sample.cpp ========================== int main(int argc, char* argv[]) { int a = 0; int b = 0; int X = 0; auto lf1 = [&a,&b,&X] (int x) {return x > 0;}; auto lf2 = [a,b] (int x) { x++; return x;}; auto lf3 = [=] (int x) { x++; return x;}; auto lf4 = [&] (int x) { x++; return x;}; auto lf5 = [] (bool& z) { z = !z; return;}; return 0; } //====================== end of sample.cpp ========================== </pre> Какие из приведённых в примере лямбда функций могут изменить значения переменных а и b?
<pre> //====================== start of sample.cpp ========================== class ARef { public: ARef(A &a, int i) : _a(a), _ix(i) {} ARef& operator= (T t) { return *this;} operator T() {return _t;} operator A() {return _a;} A& getA() { return _a;} bool operator == (A& a) {return _a == a;} private: A& _a; int _ix; T _t; }; class A { friend class ARef; public: A() {} ARef operator[] (int ix) {return ARef(*this, ix);} operator ARef() {return ARef(*this, ix);} }; //====================== end of sample.cpp ========================== </pre> Какие из методов класса ARef из файла sample.cpp являются необходимыми для поддержки идиомы контекстно-зависимой перегрузки операции индексирования агрегата?