1// (C) Copyright Terje Slettebo 2001. 2// (C) Copyright John Maddock 2001. 3// Use, modification and distribution are subject to the 4// Boost Software License, Version 1.0. (See accompanying file 5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7// See http://www.boost.org/libs/config for most recent version. 8 9// MACRO: BOOST_HAS_NRVO 10// TITLE: Named return value optimisation. 11// DESCRIPTION: Named return value optimisation. 12 13 14namespace boost_has_nrvo 15{ 16 17class test_class 18{ 19public: 20 test_class() {} 21 test_class(const test_class&) 22 { 23 ++copy_count; 24 } 25 26 static int copy_count; 27}; 28 29int test_class::copy_count; 30 31test_class f() 32{ 33 test_class nrv; 34 35 return nrv; 36} 37 38int test() 39{ 40 test_class::copy_count=0; 41 42 f(); 43 44 return test_class::copy_count; 45} 46 47} // namespace boost_has_nrvo 48 49 50 51 52 53 54 55 56 57 58