BigMan said:
Should the following piece of code compile or not
according the C++ standard? Why?
Did you try to compile it?
Your compiler will tell you whether it will compile or not
and, if not, it will tell you why.
If you are suspicious that your compiler
does not comply with ANSI/ISO C++ standards,
you can compile with the Comeau online compiler:
http://www.comeaucomputing.com/tryitout/
Compilers, especially the Comeau C++ compiler are much more reliable
than subscribers to the comp.lang.c++ newsgroup
when it comes to deciding
whether any program is a valid C++ program or not.
class t {
public:
t(void) { }
t(t& a) { }
template<typename ttt>
t(ttt) { }
};
int main(int argc, char* argv[]) {
t a;
t b = 1;
return 0;
}
g++ -Wall -ansi -pedantic -o main main.cpp
main.cpp: In function `int main(int, char**)':
main.cpp:12: error: no matching function for call to `t::t(t)'
main.cpp:4: note: candidates are: t::t(t&)
main.cpp:12: error: initializing temporary \
from result of `t::t(ttt) [with ttt = int]'