Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it incorrect to modify a temporary?

Tags:

c++

In C++98/03/11 the following code is valid:

std::string meow() { return "meow"; }

int main()
{
    meow().append("purr");
    return 0;
}

Since the temporary dies at the semi-colon, this should be safe right?

like image 800
user4112979 Avatar asked Oct 06 '14 11:10

user4112979


People also ask

Can temporary orders be modified in Texas?

When can you modify a temporary order? If the temporary order is the still in the “drafting phase” and not yet signed by a judge, you may revise it. With the assistance of your Counsel, you can edit the agreed order (if both parents can agree); in the alternative, you can request a revision of your drafted order.

How long are temporary orders good for in Texas?

In Texas, a TRO lasts for 14 days or until your temporary orders hearing, whichever is first. But what about after the hearing? If a set of temporary orders worked for all family members, then the court might choose to turn the temporary order into a permanent or final order to finalize the divorce.

How do I appeal a temporary order in Texas?

Yes, you can ask the Judge to change temporary orders by filing a Motion to Modify Temporary Orders. However, you must be able show a significant change in circumstances. Talk with a lawyer first. It may make more sense to set your case for a final hearing.

What is a temporary orders hearing Texas?

A temporary orders hearing in Texas is a full evidentiary hearing with testimony and documentary exhibits before a family court judge. The judge will hear the supporting evidence presented by you and your spouse before deciding which temporary orders are best.


1 Answers

It is not incorrect and it is useful to do this in certain circumstances.

Suppose I have a vector with a lot of data and I want to clear the data and the memory..

{ 
   std::vector< int >().swap( myVec );
}

will clear the memory for certain. myVec.clear() will probably only change the logical size back to 0.

As I showed in a previous question you can use it like this:

class Foo
{
   public:
       Foo& operator+=( Foo const& ); // implement
       Foo operator+( Foo const& rhs ) const
       {
          return Foo( *this ) += rhs;
       }
 };

The implementation there modifies a temporary then returns it by value (r-value reference in C++11, by value in C++03).

Obviously with r-value references you have more examples like in your case you can return meow().append( "purr")

like image 65
CashCow Avatar answered Oct 12 '22 23:10

CashCow