<pre> //====================== start of sample.cpp ========================== #include <type_traits> class A { public: A(int in = 5); }; int main() { std::true_type my_true; std::false_type my_false; return 0; } //====================== end of sample.cpp ========================== </pre> Какие утверждения о переменных my_true и my_false верны?
<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 <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 ========================== 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 ========================== #include <vector> template <class Storage, int size> class Input { public: Input() : m_store(size) {} private: Storage m_store; }; int main() { Input<int,5> a1; Input<int,6> a2; Input<std::vector<int>,10> v3; Input<std::vector<short>,10> v4; Input<double, 30> *pMyInput = nullptr; return 0; } //====================== end of sample.cpp ========================== </pre> Сколько описаний пользовательских типов будет в скомпилированном коде из файла 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> Какие лямбда функции из примера выше имеют доступ к значению переменной X?
<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 являются необходимыми для поддержки идиомы контекстно-зависимой перегрузки операции индексирования агрегата?
<pre> //====================== start of sample.cpp ========================== int main(int argc, char* argv[]) { const int a = 0; int b = 0; const int X = 0; int Y = 0; int Z = 0; auto lf1 = [&Y, Z, &a, &b, X] (double x) {return x > 0;}; return 0; } //====================== end of sample.cpp ========================== </pre> Значения каких переменным лямбда функция lf1 может изменить?
<pre> //====================== start of sample.cpp ========================== #include <algorithm> #include <vector> int main(int argc, char* argv[]) { std::vector<int> v1; auto lf1 = [] (int x) {return x > 0;}; auto lf3 = [] (int& x) { x++; return;}; auto lf5 = [] (bool& z) { z = !z; return;}; int cnt1 = std::count_if(v1.begin(), v1.end(), lf1); int cnt2 = std::count_if(v1.begin(), v1.end(), [] (int x) -> bool {return x+1;}); int cnt3 = std::count_if(v1.begin(), v1.end(), lf3); int cnt4 = std::count_if(v1.begin(), v1.end(), [] (int x, int& y) -> double {return x+y;}); int cnt5 = std::count_if(v1.begin(), v1.end(), lf5); return cnt1; } //====================== end of sample.cpp ========================== </pre> При вычислении каких переменных лямбда-функции в алгоритме count_if используются корректно?