Skip to content

Commit

Permalink
Update main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy authored and pezy committed Jan 11, 2015
1 parent 0221a46 commit e9e750d
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions ch13/ex13.56.57.58/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,20 @@
//! Exercise 13.58: Write versions of class Foo with print statements in their
//! sorted functions to test your answers to the previous two exercises.
//!



#include <utility>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iostream>
#include "Alan.h"
#include "StrBlob.h"

class Foo
{
public:
Foo sorted() &&; // may run on modifiable rvalues
Foo sorted() const &; // may run on any kind of Foo
// other members of Foo
private:
std::vector<int> data;
};

//! cause infinit recursion
//! infinit recursion
/*
Foo Foo::sorted() const &
{
Expand All @@ -57,30 +50,19 @@ Foo Foo::sorted() const &
Foo Foo::sorted() &&
{
std::sort(data.begin(), data.end());
std::cout << "Rvalue version\n";
return *this;
}
Foo Foo::sorted() const &
{
std::cout << "Lvalue version\n";
return Foo(*this).sorted();
}

int main()
{
Foo foo;
foo.sorted();

alan("main() is returned\n");

std::cout << "exit\n";
return 0;
}











0 comments on commit e9e750d

Please sign in to comment.