From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.etersoft.ru 7C90F6D6383 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=etersoft.ru; s=dkim; t=1503612789; bh=X7PiEMi6q02iWxSR4C//AQw4mllyrrWDkPkyVhGygUU=; h=To:From:Subject:Date:From; b=tB5902pmnDSJp+ueCak/fcSLAG9y6QROwmx7SzaNy8RPl7xFuDCv/Ya9qF85cY1ws SorNPExvT8AirrrUBtcDA4VFIowh+ZRjFbyD3A9PDFfQTpvI8DUFpOdOPXHCuVDBDw ENuYhPnRksLCwKWNw8hFIzVZCPmrhWkRzkIpEdd4= To: ALT Linux Community general discussions From: Pavel Vainerman Message-ID: <101a26f1-1b29-ca8d-c1f3-d86b8797ef91@etersoft.ru> Date: Fri, 25 Aug 2017 01:13:08 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: [Comm] =?utf-8?b?0J7RiNC40LHQutCwICjQuNC70Lgg0L3QtdGCPykg0LIgc3Rk?= =?utf-8?q?=3A=3Apartition?= X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 22:13:11 -0000 Archived-At: List-Archive: List-Post: Добрый день. Обнаружил тут странное поведение у std::partition(). Вот тестовый код (c++11). #include #include #include #include using namespace std; void print( vector& v ) { for( const auto& i: v ) cout << setw(3) << i; cout << endl; } int main() { vector v = { -10, 0, -4, 5, -2 , 0, 3, 1, 7, 8, 9 }; print(v); std::partition(v.begin(),v.end(),[](int v){ return v<0; }); print(v); return 0; } Вот результат (первая строка, исходный вектор, вторая преобразованный, опорный элемент 0). -10 0 -4 5 -2 0 3 1 7 8 9 -10 -2 -4 5 0 0 3 1 7 8 9 Так вот смущает меня почему "5" не правее нулей? Может ли кто-нибудь пояснить, почему так? -- Pavel Vainerman www.etersoft.ru