This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bog report - feature request constant function result as template argument
- To: gcc-bugs at gcc dot gnu dot org
- Subject: bog report - feature request constant function result as template argument
- From: Christian <chth at gmx dot net>
- Date: Thu, 04 May 2000 14:36:50 +0200
This is not really a bug cause it's defined as "shall be" in ISO C++.
But nevermind most other compilers support this and of course it will be
usefull.
i'm told that VC++ BC and also the Cygwin port of gcc support such
feature ...
actually i'm using a structure with a static const member as workaroud
so it doesn't hurt.
bash-2.03$ cat test.cc
#include <iostream>
template <class C> const int& ifeature() // template <class C> int
ifeature() dont work either
{
static const int r=666; //
return r; // return 666; failed too
};
template < class C,int F=ifeature<C>() >
class example
{
public:
example(){std::cout<<F<<endl;}
};
main()
{
example< int > n;
}
bash-2.03$ g++ test.cc
test.cc: In function `int main()':
test.cc:18: non-constant `ifeature<int>()' cannot be used as template
argument
test.cc:18: ANSI C++ forbids declaration `n' with no type
bash-2.03$ g++ --version
2.95.2
regards Christian