Главная » Просмотр файлов » Стандарт C++ 11

Стандарт C++ 11 (1119564), страница 79

Файл №1119564 Стандарт C++ 11 (Стандарт C++ 11) 79 страницаСтандарт C++ 11 (1119564) страница 792019-05-09СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 79)

— end note ]10The implicitly-declared move constructor for class X will have the formX::X(X&&)11An implicitly-declared copy/move constructor is an inline public member of its class. A defaulted copy/move constructor for a class X is defined as deleted (8.4.3) if X has:— a variant member with a non-trivial corresponding constructor and X is a union-like class,— a non-static data member of class type M (or array thereof) that cannot be copied/moved becauseoverload resolution (13.3), as applied to M’s corresponding constructor, results in an ambiguity or afunction that is deleted or inaccessible from the defaulted constructor,— a direct or virtual base class B that cannot be copied/moved because overload resolution (13.3), asapplied to B’s corresponding constructor, results in an ambiguity or a function that is deleted orinaccessible from the defaulted constructor,— any direct or virtual base class or non-static data member of a type with a destructor that is deletedor inaccessible from the defaulted constructor,— for the copy constructor, a non-static data member of rvalue reference type, or— for the move constructor, a non-static data member or direct or virtual base class with a type thatdoes not have a move constructor and is not trivially copyable.12A copy/move constructor for class X is trivial if it is not user-provided and if— class X has no virtual functions (10.3) and no virtual base classes (10.1), and— the constructor selected to copy/move each direct base class subobject is trivial, and— for each non-static data member of X that is of class type (or array thereof), the constructor selectedto copy/move that member is trivial;119) This implies that the reference parameter of the implicitly-declared copy constructor cannot bind to a volatile lvalue;see C.1.9.§ 12.8280© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)otherwise the copy/move constructor is non-trivial.13A copy/move constructor that is defaulted and not defined as deleted is implicitly defined if it is odr-used (3.2)to initialize an object of its class type from a copy of an object of its class type or of a class type derivedfrom its class type120 or when it is explicitly defaulted after its first declaration.

[ Note: The copy/moveconstructor is implicitly defined even if the implementation elided its odr-use (3.2, 12.2). — end note ] Ifthe implicitly-defined constructor would satisfy the requirements of a constexpr constructor (7.1.5), theimplicitly-defined constructor is constexpr.14Before the defaulted copy/move constructor for a class is implicitly defined, all non-user-provided copy/moveconstructors for its direct and virtual base classes and its non-static data members shall have been implicitlydefined. [ Note: An implicitly-declared copy/move constructor has an exception-specification (15.4). — endnote ]15The implicitly-defined copy/move constructor for a non-union class X performs a memberwise copy/moveof its bases and members.

[ Note: brace-or-equal-initializers of non-static data members are ignored. Seealso the example in 12.6.2. — end note ] The order of initialization is the same as the order of initializationof bases and members in a user-defined constructor (see 12.6.2). Let x be either the parameter of theconstructor or, for the move constructor, an xvalue referring to the parameter. Each base or non-static datamember is copied/moved in the manner appropriate to its type:— if the member is an array, each element is direct-initialized with the corresponding subobject of x;— if a member m has rvalue reference type T&&, it is direct-initialized with static_cast<T&&>(x.m);— otherwise, the base or member is direct-initialized with the corresponding base or member of x.Virtual base class subobjects shall be initialized only once by the implicitly-defined copy/move constructor(see 12.6.2).16The implicitly-defined copy/move constructor for a union X copies the object representation (3.9) of X.17A user-declared copy assignment operator X::operator= is a non-static non-template member function ofclass X with exactly one parameter of type X, X&, const X&, volatile X& or const volatile X&.121 [ Note:An overloaded assignment operator must be declared to have only one parameter; see 13.5.3.

— end note ][ Note: More than one form of copy assignment operator may be declared for a class. — end note ] [ Note:If a class X only has a copy assignment operator with a parameter of type X&, an expression of type const Xcannot be assigned to an object of type X. [ Example:struct X {X();X& operator=(X&);};const X cx;X x;void f() {x = cx;// error: X::operator=(X&) cannot assign cx into x}— end example ] — end note ]120) See 8.5 for more details on direct and copy initialization.121) Because a template assignment operator or an assignment operator taking an rvalue reference parameter is never acopy assignment operator, the presence of such an assignment operator does not suppress the implicit declaration of a copyassignment operator. Such assignment operators participate in overload resolution with other assignment operators, includingcopy assignment operators, and, if selected, will be used to assign an object.§ 12.8© ISO/IEC 2011 – All rights reserved281ISO/IEC 14882:2011(E)18If the class definition does not explicitly declare a copy assignment operator, one is declared implicitly.

Ifthe class definition declares a move constructor or move assignment operator, the implicitly declared copyassignment operator is defined as deleted; otherwise, it is defined as defaulted (8.4). The latter case isdeprecated if the class has a user-declared copy constructor or a user-declared destructor. The implicitlydeclared copy assignment operator for a class X will have the formX& X::operator=(const X&)if— each direct base class B of X has a copy assignment operator whose parameter is of type const B&,const volatile B& or B, and— for all the non-static data members of X that are of a class type M (or array thereof), each such classtype has a copy assignment operator whose parameter is of type const M&, const volatile M& or M.122Otherwise, the implicitly-declared copy assignment operator will have the formX& X::operator=(X&)19A user-declared move assignment operator X::operator= is a non-static non-template member function ofclass X with exactly one parameter of type X&&, const X&&, volatile X&&, or const volatile X&&.

[ Note:An overloaded assignment operator must be declared to have only one parameter; see 13.5.3. — end note ][ Note: More than one form of move assignment operator may be declared for a class. — end note ]20If the definition of a class X does not explicitly declare a move assignment operator, one will be implicitlydeclared as defaulted if and only if— X does not have a user-declared copy constructor,— X does not have a user-declared move constructor,— X does not have a user-declared copy assignment operator,— X does not have a user-declared destructor, and— the move assignment operator would not be implicitly defined as deleted.[ Example: The class definitionstruct S {int a;S& operator=(const S&) = default;};will not have a default move assignment operator implicitly declared because the copy assignment operatorhas been user-declared.

The move assignment operator may be explicitly defaulted.struct S {int a;S& operator=(const S&) = default;S& operator=(S&&) = default;};— end example ]21The implicitly-declared move assignment operator for a class X will have the form122) This implies that the reference parameter of the implicitly-declared copy assignment operator cannot bind to a volatilelvalue; see C.1.9.§ 12.8282© ISO/IEC 2011 – All rights reservedISO/IEC 14882:2011(E)X& X::operator=(X&&);22The implicitly-declared copy/move assignment operator for class X has the return type X&; it returns theobject for which the assignment operator is invoked, that is, the object assigned to. An implicitly-declaredcopy/move assignment operator is an inline public member of its class.23A defaulted copy/move assignment operator for class X is defined as deleted if X has:— a variant member with a non-trivial corresponding assignment operator and X is a union-like class, or— a non-static data member of const non-class type (or array thereof), or— a non-static data member of reference type, or— a non-static data member of class type M (or array thereof) that cannot be copied/moved becauseoverload resolution (13.3), as applied to M’s corresponding assignment operator, results in an ambiguityor a function that is deleted or inaccessible from the defaulted assignment operator, or— a direct or virtual base class B that cannot be copied/moved because overload resolution (13.3), asapplied to B’s corresponding assignment operator, results in an ambiguity or a function that is deletedor inaccessible from the defaulted assignment operator, or— for the move assignment operator, a non-static data member or direct base class with a type that doesnot have a move assignment operator and is not trivially copyable, or any direct or indirect virtualbase class.24Because a copy/move assignment operator is implicitly declared for a class if not declared by the user, abase class copy/move assignment operator is always hidden by the corresponding assignment operator of aderived class (13.5.3).

Характеристики

Тип файла
PDF-файл
Размер
14,26 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов учебной работы

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6358
Авторов
на СтудИзбе
311
Средний доход
с одного платного файла
Обучение Подробнее