15,667,248 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Python questions
View Javascript questions
View C++ questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by AndreFratelli (Top 40 by date)
AndreFratelli
10-Jul-12 20:42pm
View
No, I don't. I was just stating that I read the documentation and I understood it. Not sure what you mean by "forward documents"...
Well, not the case.
I believe I said this in my previous post: "The statement I have above should evaluate to bool, which is pretty much castable to int. So don't feel ashamed". Are you adding anything to it?
Still don't get it why I'm casting to bool? Ok... Can I vote 1 again?
Like I said, I understood your answer. Are you understanding the question? Here's an hint:
if ((bool)1 == (bool)2) { cout << "Native bool" << endl; }
Now do the same without casting.
Edit: wrong thread.
AndreFratelli
10-Jul-12 20:42pm
View
Deleted
No, I don't. I was just stating that I read the documentation and I understood it. Not sure what you mean by "forward documents"...
Well, not the case.
I believe I said this in my previous post: "The statement I have above should evaluate to bool, which is pretty much castable to int. So don't feel ashamed". Are you adding anything to it?
Still don't get it why I'm casting to bool? Ok... Can I vote 1 again?
Like I said, I understood your answer. Are you understanding the question? Here's an hint:
if ((bool)1 == (bool)2) { cout << "Native bool" << endl; }
Now do the same without casting.
AndreFratelli
10-Jul-12 13:43pm
View
Actually, the error message *is* about the #if directive, check the documentation yourself ;) "if they are used in an #if, #elif, or #else directive."
Why do you say that operator== doesn't evaluate to an integer constant? This is legal:
#if 1 == 1
The statement I have above should evaluate to bool, which is pretty much castable to int. So don't feel ashamed and explain to me why does the compiler complain about this...
Because if I don't cast to bool than it's an int comparison? 1 == 2 would be pretty obvious... However, if you have native bools (not sure if in all compilers) (bool)1 == (bool)2 is actually true! Guess what: I'm trying to check if the compiler has native bool support... Makes much sense to me.
Why do people always assume others haven't read the documentation? I've been using the preprocessor for 10+ years by now...
AndreFratelli
23-Jun-12 14:22pm
View
I didn't test it, it just says on the site that it doesn't support it... But that's a good point, though. Is it supposed to be supported in C++?
AndreFratelli
23-Jun-12 8:53am
View
The question is there...
AndreFratelli
7-Jun-12 13:44pm
View
Yeah, it kind of loses its purpose...
AndreFratelli
6-Jun-12 21:04pm
View
That would catch the exceptions not listed in the catch blocks, not the one not listed in the function declaration.
What I make of this: it can't be done. If VS doesn't support exception specification there is no way to know if an exception is not specified. Hell, none is.
AndreFratelli
6-Jun-12 20:51pm
View
I agree.
AndreFratelli
6-Jun-12 20:46pm
View
And I can confirm it. I tested it.
AndreFratelli
6-Jun-12 20:07pm
View
Yes, VC doesn't even support exception specification (http://msdn.microsoft.com/en-us/library/sa28fef8.aspx), so it doesn't even make sense to talk about unexpected exceptions there.
Anyway, how would you suggest that to be done at the compiler level?
AndreFratelli
6-Jun-12 13:02pm
View
that is what I call an awesome answer! =)
I didn't take exactly the same approach, though. But the idea to pass an encapsulated array to the constructor gave me an idea. So I did this:
<pre>
// "const_array" and "array" are inner classes, size_type and T are defined in the parent class
template < size_type _Capacity > class const_array
{
public:
const T& operator[](size_type index) const { ... }
protected:
T items[_Capacity];
};
template < size_type _Capacity > class array
: public const_array<_Capacity>
{
public:
T& operator[](size_type index) { /* not const */ }
};
</pre>
Now, to initialize first construct an "array" and pass it to "const_array". Worked like a charm =)
What do you think?
Thank you!
AndreFratelli
14-Apr-12 14:46pm
View
Appreciated ;)
Cheers.
AndreFratelli
14-Apr-12 9:53am
View
My later experiments seem to suggest that the only problem will be with DLLs. It seems the compiler actually tries to compile the templates when they are exported in a DLL. Unfortunately, this really is to export in a DLL.
Anyway, the conditions have changed and I can't even use STL at all! It seems some target platforms do not support it, don't really know which. That said, I wrote my own implementation of red-black trees and I'm using them in the slots of an hash table (it's even more efficient). But I'll take a look at those compilers ;)
Actually the class being mapped was written by me. I usually insist in designing my apps as well as I can and I believe that a default constructor should not be there when a class shouldn't support default construction. This is the case. It has a mandatory argument. Of course I could work around this and allow default construction and then allow setting the value with a setter. But then again, it would allow default construction =) it's just a design issue.
Thank you for your reply!
Regards
AndreFratelli
8-Apr-12 10:02am
View
I was kind of fearing that :P
std::map::operator [] does one of two things:
1) Return a reference to an existing value with the given key; or
2) Instantiate a new value using the default constructor and associate it with the key.
So what to do when a default constructor is not available? I inherited from std::map (assoc_map) and allow the passage of a default value at construction time.
Then I overload operator[] and copy the default instance instead of propagating to std::map::operator[], when the value does not exist.
This works because it's a template class and, therefore, its methods only get compiled when a specialization exists for them. What I would like to know is if this is indeed true. If an attempt exists to try to compile std::map::operator[] it will complain that the default constructor is not available, even though that does not happen in VS08.
Thank you
AndreFratelli
1-Apr-12 18:10pm
View
I'm sorry, didn't notice this before. andre.fratelli@hotmail.com
Thanks!
AndreFratelli
29-Mar-12 4:19am
View
You are? Why?
Where do I send it to?
Thx!
AndreFratelli
28-Mar-12 11:04am
View
Maybe a bug report, then?
AndreFratelli
28-Mar-12 10:47am
View
Indeed, I'm not inlining it anymore. I posted because I think it's odd and couldn't understand the reason. Right know I just wan't to understand it =)
regards
AndreFratelli
28-Mar-12 10:45am
View
Sorry, didn't notice that last line. Yes, I did. Please note that not inlining the operator works, so everything else works.
AndreFratelli
28-Mar-12 10:19am
View
Deleted
Yes, I know. Everybody please note that the issue here is not inlining, nor it is putting the code to work. The issue is: why does declaring a method inline hields unresolved externals, but not inline, doesn't.
AndreFratelli
28-Mar-12 8:25am
View
Yes, I know all that. Writing the body with the declaration (in the header file) gives other unresolved externals, oddly enough:
Error 1 error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const & __thiscall SGEEmotion::id(void)const " (?id@SGEEmotion@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: bool __thiscall SGEEmotion::Comparator::operator()(class SGEEmotion const &,class SGEEmotion const &)const " (??RComparator@SGEEmotion@@QBE_NABV1@0@Z) SGEMood.obj
AndreFratelli
28-Mar-12 8:19am
View
I've read it, and I know what inlining is. I don't get the point you're trying to make..
AndreFratelli
28-Mar-12 8:11am
View
Hi, please see my reply above. Thx!
AndreFratelli
28-Mar-12 8:10am
View
It's SGEEmotion::Comparator::operator ()
Error 1 error LNK2019: unresolved external symbol "public: bool __thiscall SGEEmotion::Comparator::operator()(class SGEEmotion const &,class SGEEmotion const &)const " (??RComparator@SGEEmotion@@QBE_NABV1@0@Z) referenced in function "public: float & __thiscall std::map<class sgeemotion,float,class="" sgeemotion::comparator,class="" std::allocator<struct="" std::pair<class="" sgeemotion="" const="" ,float=""> > >::operator[](class SGEEmotion const &)" (??A?$map@VSGEEmotion@@MVComparator@1@V?$allocator@U?$pair@$$CBVSGEEmotion@@M@std@@@std@@@std@@QAEAAMABVSGEEmotion@@@Z) SGEMood.obj
AndreFratelli
5-Mar-12 12:57pm
View
This:
freeglut_static.lib(freeglut_main.obj) : error LNK2001: unresolved external symbol __iob
AndreFratelli
5-Feb-12 4:13am
View
I posted in the C# forum? =\ didn't even realise..
AndreFratelli
4-Feb-12 16:11pm
View
It's neither, actually. The problem arose while developing a Qt application, but still, I'm interested in the more abstract idea of the object handling the thread dying before the thread does.
AndreFratelli
3-Feb-12 11:26am
View
Ah, so without that call it wouldn't be call at all?
AndreFratelli
3-Feb-12 11:24am
View
QWidget and QGLWidget are Qt classes, so I really can't do anything.
AndreFratelli
3-Feb-12 7:47am
View
1) The only thing they have in common is QWidget. Doesn't it just need to be virtual somewhere in the inheritance tree?
2) Nice =)
3) What do you mean the most specified? The one that's supposed to be called more times?
4) Oh my...
I was exploring the virtual inheritance approach, but I see I have more to lose then I have to gain here... I think I'll just QWidget as the base class and drop the Widget class at all.
Thank you for your patience!
Best.
AndreFratelli
3-Feb-12 7:42am
View
I did read about it. That's how I got this questions in the first place =)
What do you mean no matter what? Isn't that what virtual inheritance is supposed to do? =\
Thanks!
AndreFratelli
4-Jul-11 11:36am
View
Oh.. =\ I get it.
AndreFratelli
4-Jul-11 11:33am
View
I don't think so. You have to fetch the data and apply the algorithm to it outside the database. I don't recommend it though.. Instead, you should save paths and store clustered information about the files (using IDs).
AndreFratelli
3-Jul-11 13:20pm
View
Oh, Ok. But why strike?
(did I just double post? I'm still figuring out some details on this interface =P)
AndreFratelli
3-Jul-11 13:19pm
View
Deleted
Oh, ok. But why strike?
AndreFratelli
3-Jul-11 13:18pm
View
I'm not "cheers"... See
here
Sorry, but can you be a bit clearer? I don't understand what you'r saying...
AndreFratelli
2-Jul-11 15:34pm
View
Sorry, what? =\
AndreFratelli
2-Jul-11 12:07pm
View
Actually, no, I don't quite get your questions...
In the first one are you trying to know how the {n} marks associate with the arguments? If so, take a look at varargs, you could write something similar with it.
As to the second one, empirically I would say you are trying to insert something at the beginning of a dictionary. Is that it? If so, then it makes no sense because dictionaries are not ordered.
AndreFratelli
2-Jul-11 2:06am
View
I don't really know D3D, only OpenGL. But still, why would you need to access the texture's data to detect collisions? I recently wrote a collision detection system, and I think you are taking the wrong approach here. Have you considered other options to "pixel" collision detection? Bound-boxes, Octrees, Triangle-triangle collisions..
Anyway, whenever you want something transformed, you better transform it in CPU (assuming you are not transforming ** everything ** in a mesh, instead of just whatever needs to be checked).
regards
AndreFratelli
2-Jul-11 1:45am
View
Since you are already using structs, you could also go old school and implement a linked list yourself. STL is probably a better option, though.
Moved this comment so OP gets it.
Show More