[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Not implemented...
From:       Carlo Wood <carlo () runaway ! xs4all ! nl>
Date:       1999-04-21 1:11:03
[Download RAW message or body]

Hey guys,

is this implemented in the latest version?

I need it! :)

~/c++/libr/src/io/tests>g++ ios_tst.cc
ios_tst.cc:34: sorry, not implemented: `template_type_parm' not supported by dump_decl

Included below a test case that compiles and runs correctly on this
IRIX box, using their `CC' - but gives the above error with egcs-1.1.1
on my linux box.

-- 
 Carlo Wood  <carlo@runaway.xs4all.nl>

---ios_tst.cc-----------------------------------------------------------------
#include <iostream.h>
#include <iomanip.h>
#include <vector.h>
#include <algo.h>

template<class MANIP_DATA>
class manip_id_tct {
  MANIP_DATA manip_data;
  const streambuf *id;
public:
  manip_id_tct(const streambuf *sb) : manip_data(), id(sb) { }
  bool operator!=(const streambuf *sb) const { return id != sb; }
  const MANIP_DATA &get_manip_data(void) const { return manip_data; }
  MANIP_DATA &get_manip_data(void) { return manip_data; }
};

template<class TYPE>
inline typename TYPE::manip_data_ct &get_manip_data(const ostream &os, const TYPE)
{
  typedef manip_id_tct<typename TYPE::manip_data_ct> manip_id_ct;
  static vector<manip_id_ct> ids;
  vector<manip_id_ct>::iterator i;
  i = find(ids.begin(), ids.end(), const_cast<ostream&>(os).rdbuf());
  if (i == ids.end())
    i = ids.insert(ids.end(), manip_id_ct(const_cast<ostream&>(os).rdbuf()));
  return (*i).get_manip_data();
}

template <class TYPE, class TP> class rmanip {
public:
  typedef typename TYPE::manip_data_ct manip_data_ct;
  ostream& (manip_data_ct::*_f)(TP);
  TP _a;
  rmanip(ostream& (manip_data_ct::*f)(TP), TP a) : _f(f), _a(a) { }
};

#define __DEFINE_RMANIP_FUNC1(TYPE, function, paramT) \
  static rmanip<TYPE, paramT> function(paramT n) \
  { \
    return rmanip<TYPE, paramT>(&manip_data_ct::__rmanip_##function, n); \
  } \
  friend inline ostream& operator<<(ostream &os, const rmanip<TYPE, paramT>& m) \
  { \
    return (get_manip_data<TYPE>(os).*m._f)(m._a); \
  }

// Start foo test:

class foo_md_ct {
  int w;
public:
  foo_md_ct(void) : w(-1) { }
  foo_md_ct(int _w) : w(_w) { }
  int get_w(void) const { return w; }
  ostream &__rmanip_setw(int _w) { w = _w; return cout; }
};

class foo {
  typedef foo_md_ct manip_data_ct;
  int i;
public:
  foo(void) : i(123) { }
  friend ostream &operator<<(ostream &os, const foo &f);
  static rmanip<foo, int> setw(int n)
  {
    return rmanip<foo, int>(&manip_data_ct::__rmanip_setw, n);
  }
  friend inline ostream& operator<<(ostream &os, const rmanip<foo, int>& m)
  {
    foo f;
    return (get_manip_data(os, f).*m._f)(m._a);
  }
};

ostream &operator<<(ostream &os, const foo &f)
{
  foo::manip_data_ct &md(get_manip_data(os, f));
  int w = md.get_w();
  if (w >= 0)
    os << setw(w);
  os << f.i;
  return os;
}

int main(void)
{
  foo f;
  cout << foo::setw(5) << f << endl;
  return 0;
}

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic