[Boost-bugs] [Boost C++ Libraries] #1067: Function needs to use pass-by-reference internally

Subject: [Boost-bugs] [Boost C++ Libraries] #1067: Function needs to use pass-by-reference internally
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2007-06-27 11:04:51


#1067: Function needs to use pass-by-reference internally
----------------------------+-----------------------------------------------
 Reporter: dgregor | Owner: dgregor
     Type: Bugs | Status: new
Milestone: Boost 1.35.0 | Component: function
  Version: release 1.34.0 | Severity: Optimization
 Keywords: |
----------------------------+-----------------------------------------------
 Boost.Function uses pass-by-value internally for the function object.
 While it is unspecified how many times the function object would be
 copied, we should still minimize this amount. The following code snippet
 illustrates how many copy constructions are performed.

 struct Functor
 {
     Functor(void)
         { std::cout << "Functor constructor (" << this << ')' <<
 std::endl; }
     Functor(const Functor&)
         { std::cout << "Functor copy constructor (" << this << ')' <<
 std::endl; }
     ~Functor(void)
         { std::cout << "Functor destructor (" << this << ')' << std::endl;
 }

     void operator()(void) const
         { std::cout << "Hello world!" << std::endl; }

     std::string memfunc(void) const
         { return std::string("hello world!!!!!!"); }
 };

 int main(void)
 {
     Functor func;
     boost::function0<void> f(func);

     return 0;
 }

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/1067>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:55 UTC