C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

C++.Coding.Standards.1918.Rules.Guidelines [Electronic resources] - نسخه متنی

Herb Sutter, Andrei Alexandrescu

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


Examples


Example: Initialization library with overloaded

operator,

for sequence initialization. One library helpfully tried to make it easier to add multiple values to a container in one shot by overloading the comma. For example, to append to a

vector<string> letters :

set_cont(letters) += "a", "b";

// problematic

That's fine until the day the caller writes:

set_cont(letters) += getstr(), getstr();

// order unspecified when using overloaded ","

If

getstr gets user console input, for example, and the user enters the strings

"c" and

"d" in that order, the strings can actually be applied in either order. That's a surprise, because this is not a problem for the built-in sequencing

operator, :

string s = getstr(), getstr();

// order well-specified using built-in ","


/ 521