/[escript]/branches/windows_from_1456_trunk_1580_merged_in/escript/src/FunctionSpace.h
ViewVC logotype

Diff of /branches/windows_from_1456_trunk_1580_merged_in/escript/src/FunctionSpace.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1603 by phornby, Wed Jun 4 07:10:43 2008 UTC revision 1604 by phornby, Sat Jun 14 10:06:31 2008 UTC
# Line 147  class FunctionSpace { Line 147  class FunctionSpace {
147     Worse still is that operator=() is exposed to python in escriptcpp.cpp.     Worse still is that operator=() is exposed to python in escriptcpp.cpp.
148    */    */
149    ESCRIPT_DLL_API    ESCRIPT_DLL_API
150    const std::string &    std::string
151    toString() const;    toString() const;
152    
153     //#define DEBUG_PY_STRINGS     //#define DEBUG_PY_STRINGS
# Line 278  class FunctionSpace { Line 278  class FunctionSpace {
278     Also, breaks the non-mutability of FunctionSpace     Also, breaks the non-mutability of FunctionSpace
279     assumed by toString().     assumed by toString().
280    */    */
   // yes, yes I know, but the test case is in another  
   // linkage unit external to the dll.  
   // This IS supposed to be a temporary fix until a more  
   // robust solution is implemented.  
281    ESCRIPT_DLL_API    ESCRIPT_DLL_API
282    FunctionSpace&    FunctionSpace&
283    operator=(const FunctionSpace& other);    operator=(const FunctionSpace& other);
# Line 298  class FunctionSpace { Line 294  class FunctionSpace {
294    // function space type code.    // function space type code.
295    int m_functionSpaceType;    int m_functionSpaceType;
296    
   //  
   // return value of toString.  
   // Made mutable for recalculation by calls to toString.  
   // This is supposed to be conceptually immutable,  
   // and the mutable declaration is intended to admit lazy init. in the  
   // 1st call to toString()  
   // Unfortunately, the existance of operator=() breaks  
   // the imutability of FunctionSpace, so the current toString()  
   // implementation is in fact an abuse of "mutable".  
   // So why not just return a std::strin & do away with this class member?  
   //  
   // 1. even if an anonymous copy of the value is returned instead of a const  
   //    reference, that value can find it's way into another DLL, especially  
   //    in this environment.  
   // 2. This is especially true of exceptions that are fed said anaonymous  
   //    copy as the retun value of a function into the argument of the  
   //    exception constructor that expects a const reference.  
   // 3. What happens is that the exception object is left holding  
   //    a reference to an onject that is going to get creamed  
   //    during stack unwind.  
   // 4. returning a class value from a stack local is frowned upon anyway,  
   //    this is just one reason not to do it.  
   // 5. There are a number of patters, all well known to C++ programmers  
   //    for avoiding the practice.  
   
   mutable std::string type_str;  
   
297  };  };
298    
299  } // end of namespace  } // end of namespace

Legend:
Removed from v.1603  
changed lines
  Added in v.1604

  ViewVC Help
Powered by ViewVC 1.1.26