File: member_function.cpp

package info (click to toggle)
blitz%2B%2B 1%3A1.0.2%2Bds-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,580 kB
  • sloc: cpp: 57,803; python: 1,941; fortran: 1,510; f90: 852; makefile: 838; sh: 321
file content (41 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "testsuite.h"
#include <blitz/array.h>

//#undef BZ_FAST_COMPILE

using namespace blitz;

// test that member function functors work. (There was a bug where
// they would use an out-of-scope temporary copy of the class itself
// if BZ_ETPARM was pass-by-value.)

class testclass {
private:
  testclass(const testclass&) {
    BZTEST(0);
  };

public:
  int d_;

  testclass(int d) : d_(d) {};

  int func(int d) const {cout << "In func, this is " << this << endl; return d_*d; };

  BZ_DECLARE_MEMBER_FUNCTION(testclass, func);
};


int main()
{
  Array<int,1> a(3), b(3);
  a=1,2,3;

  testclass t(2);
  cout << "&t is " << &t << endl;
  // this expression should not require copying t.
  b=t.func(2*a);

  return 0;
}