Re: Method should return list<>, instead returns BOOL, no error. Why not?
- From: "Alex Blekhman" <xfkt@xxxxxxxxx>
- Date: Sat, 3 Mar 2007 00:53:14 +0200
"Igor Tandetnik" wrote:
I have a class with a method that is declared to return a std::list<>
object, but instead it returns a BOOL value. However, no compiler
error is thrown. Why not?
Are you using VC6, by any chance? The code produces an error under VC7.1
BOOL is a typedef for int. std::list has a constructor that takes a single parameter of type size_t. This constructor is marked explicit in VC7.1, but I believe it was not in VC6 (I don't have it handy to check at the moment). If it's not marked explicit, this constructor can be used for type conversion. So what the compiler is doing is creating and returning a temporary instance of std::list, initialized by that one-argument constructor from the value of BOOL result.
Actually, VC6's `list' template has `explicit' specifier. Probably VC6 simply ignores it and creates an object anyway.
"list::list"
http://msdn.microsoft.com/library/en-us/vclang98/html/LIST_LISTCCLIST.asp
Alex
.
- References:
- Method should return list<>, instead returns BOOL, no error. Why not?
- From: CedricCicada
- Re: Method should return list<>, instead returns BOOL, no error. Why not?
- From: Igor Tandetnik
- Method should return list<>, instead returns BOOL, no error. Why not?
- Prev by Date: Re: Method should return list<>, instead returns BOOL, no error. Why not?
- Next by Date: Performance problem with _SECURE_SCL=0
- Previous by thread: Re: Method should return list<>, instead returns BOOL, no error. Why not?
- Next by thread: Re: Method should return list<>, instead returns BOOL, no error. Why not?
- Index(es):
Relevant Pages
|
Loading