// auto_ptr.C
// ----------------------------------------------------------------
// COMP 290-001: Algorithm Library Design, Lutz Kettner, 01/11/2000
// Example for auto_ptr.

#include <memory>

using namespace std;

auto_ptr<int> source() { return auto_ptr<int>( new int(42)); }

void sink( auto_ptr<int> pt) {}

int main() {
    // legal expressions with auto_ptr
    sink( source());
    auto_ptr<int> pt = source();
    sink( pt);
    pt = source();
    auto_ptr<int> pt2 = pt;

    const auto_ptr<int> pt3( new int(42));
    *pt3 = 43;

    const auto_ptr<const int> pt4( new int(42));
    // *pt4 = 43;  // this is now an error
}

// EOF //

