source: git/factory/include/factory/templates/ftmpl_factor.h @ aa8a7e

spielwiese
Last change on this file since aa8a7e was fb1675, checked in by Hans Schoenemann <hannes@…>, 7 years ago
use include ".." for singular related .h, p8
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifndef INCL_FACTOR_H
4#define INCL_FACTOR_H
5
6#ifndef NOSTREAMIO
7#ifdef HAVE_IOSTREAM
8#include <iostream>
9#define OSTREAM std::ostream
10#elif defined(HAVE_IOSTREAM_H)
11#include <iostream.h>
12#define OSTREAM ostream
13#endif
14#endif /* NOSTREAMIO */
15
16
17template <class T>
18class Factor {
19private:
20    T _factor;
21    int _exp;
22public:
23    Factor() : _factor(1), _exp(0) {}
24    Factor( const Factor<T> & f ) : _factor(f._factor), _exp(f._exp) {}
25    Factor( const T & f, int e ) : _factor(f), _exp(e) {}
26    Factor( const T & f ) : _factor(f), _exp(1) {}
27    ~Factor() {}
28    Factor<T>& operator= ( const Factor<T>& );
29    Factor<T>& operator= ( const T& );
30    T factor() const { return _factor; }
31    int exp() const { return _exp; }
32    T value() const { return power( _factor, _exp ); }
33    Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
34    Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
35    Factor<T>& operator*= ( const T & f ) { _factor *= f; return *this; }
36#ifndef NOSTREAMIO
37    void print ( OSTREAM& ) const;
38#endif /* NOSTREAMIO */
39};
40
41template <class T> int
42operator== ( const Factor<T>&, const Factor<T>& );
43
44#ifndef NOSTREAMIO
45template <class T>
46OSTREAM& operator<< ( OSTREAM & os, const Factor<T> & f );
47#endif /* NOSTREAMIO */
48
49#endif /* ! INCL_FACTOR_H */
Note: See TracBrowser for help on using the repository browser.