1850: Delay construction of pw::value.

https://svn.lrde.epita.fr/svn/oln/trunk Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Delay construction of pw::value. * milena/mln/pw/value.hh (value): New overload. Such function shall have a delayed construction mechanism so that 'initialize' can work. value.hh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) Index: milena/mln/pw/value.hh --- milena/mln/pw/value.hh (revision 1849) +++ milena/mln/pw/value.hh (working copy) @@ -54,8 +54,10 @@ typedef mln_value(I) result; value_(const I& ima); mln_rvalue(I) operator()(const mln_psite(I)& p) const; + + value_(); // A function should have a ctor without arg so that "initialize" can work. protected: - const I& ima_; + const I* ima_; }; @@ -74,7 +76,14 @@ template <typename I> inline value_<I>::value_(const I& ima) - : ima_(ima) + : ima_(&ima) + { + } + + template <typename I> + inline + value_<I>::value_() + : ima_(0) { } @@ -83,8 +92,9 @@ mln_rvalue(I) value_<I>::operator()(const mln_psite(I)& p) const { - mln_precondition(ima_.owns_(p)); - return ima_(p); + mln_precondition(ima_ != 0); + mln_precondition(ima_->owns_(p)); + return (*ima_)(p); } // pw::value(ima)
participants (1)
-
Thierry Geraud