mutable function argument

Discussion in 'C++' started by monarch_dodra, Sep 6, 2010.

  1. monarch_dodra

    monarch_dodra New Member

    Sep 6, 2010
    Likes Received:
    Trophy Points:
    I have a function "foo". This function takes an argument arg. foo promises not to modify arg in a visible way. In reality, foo will do all kinds of non-const operation on arg, but by the end of it all, foo will be back to normal:

    foo(const T& arg)
    arg+=2; //modify foo stuff
    arg-=2; //foo is back to normal
    An arg object is actually pretty big, so I'd like to avoid copying them unless arg is an actual const (and not just const qualified). Is there a solution to this?

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice