os/ossrv/stdcpp/tsrc/Boost_test/variant/inc/class_a.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 //-----------------------------------------------------------------------------
     2 // boost-libs variant/libs/test/class_a.h header file
     3 // See http://www.boost.org for updates, documentation, and revision history.
     4 //-----------------------------------------------------------------------------
     5 //
     6 // Copyright (c) 2003
     7 // Eric Friedman, Itay Maman
     8 //
     9 // Distributed under the Boost Software License, Version 1.0. (See
    10 // accompanying file LICENSE_1_0.txt or copy at
    11 // http://www.boost.org/LICENSE_1_0.txt)
    12 
    13 #ifndef _CLASSA_H_INC_
    14 #define _CLASSA_H_INC_
    15 
    16 #include <algorithm> // for std::swap
    17 #include <sstream>
    18 #include <iostream>
    19 #include <assert.h>
    20 #include <iosfwd>
    21 
    22 struct class_a
    23 {
    24    ~class_a();
    25    class_a(int n = 5511);
    26    class_a(const class_a& other);
    27 
    28    class_a& operator=(const class_a& rhs);
    29    void swap(class_a& other);
    30 
    31    int get() const;
    32 
    33 private:
    34    int n_;
    35    class_a* self_p_;
    36 
    37 }; //Class_a
    38 
    39 std::ostream& operator<<(std::ostream& strm, const class_a& a);
    40 
    41 using namespace std;
    42 class_a::~class_a()
    43 {
    44    assert(self_p_ == this);
    45 }
    46 
    47 class_a::class_a(int n)
    48 {
    49    n_ = n;
    50    self_p_ = this;
    51 }
    52 
    53 class_a::class_a(const class_a& other)
    54 {
    55    n_ = other.n_;
    56    self_p_ = this;
    57 }
    58 
    59 
    60 class_a& class_a::operator=(const class_a& rhs)
    61 {
    62    class_a temp(rhs);
    63    swap(temp);
    64 
    65    return *this;
    66 }
    67 
    68 void class_a::swap(class_a& other)
    69 {
    70    std::swap(n_, other.n_);
    71 }
    72 
    73 int class_a::get() const
    74 {
    75    return n_;
    76 }
    77 
    78 std::ostream& operator<<(std::ostream& strm, const class_a& a)
    79 {
    80    return strm << "class_a(" << a.get() << ")";
    81 }
    82 
    83 #endif //_CLASSA_H_INC_