| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13
Comments:
<0> night <1> anyone know where I can download code that will create a 3D geodesic sphere? <2> @quran search divorce <2> whooops.. wrong chan <3> http://www.vb-helper.com/howto_geodesic_sphere.html <1> thank you <4> hey all :) I have a cl*** containing a list attribute (STL) which is allocated on the stack... how would i return a pointer or reference to this list instance using a method ? <5> std::list& myfunction(); <4> thankyou :) <5> then just return mylist; within the function <4> what is the std::list::pointer for by the way? just out of interest <5> what? <5> oh <3> I thought it was pointer_type <3> Or maybe that's what I use <3> Heheh
<5> no it's just pointer <6> Antrix: You shouldn't return a reference to an object on the stack. <5> hmm I never knew that even existed <4> hmm yeh, i should allocate memory for it on the heap i guess <5> it's an Alloc::pointer MrAshe <3> list<T>::pointer p = &*it; <3> ph34r <4> can i dynamically allocate memory using the short-list constructor ? <4> or will i need to do it normally <3> Btw std::list & myfunction() is fine <4> std::list<std::string>& getItems(); <4> ;) <3> Though I'd add a std::list const & myfunction() const too <5> ya was just about to say <4> good point <5> make it const <4> cheers, you legends <5> so that stupid things like myfunc() = list say no <3> And being on the stack or not doesn't really matter, it depends of where you instantiate the object anyway <4> mm <4> would you say that its generally better to not use "using namespace std" ? <5> yes. <3> Dunno, depends where you want to use it <4> thought so, cool :) <4> yeah, but i guess you could use using namespace std { block using it very frequently here } <3> Hm? <4> or am i being a complete hobknob <4> anyway thx that was pretty helpful, i'll stick around <3> If you have some header you'll include everywhere and put a using namespace std; right in the middle <3> Then it's most likely a bad thing <3> If you have some if (blah) { using namespace std; .. plenty of std:: stuff here .. } <3> Then it looks fine <3> Note that you can also do using std::list<T>; <4> yeah :) <6> Hrmpf... this compiles: <6> (b1 && b2)->operator()(a, &A::callback); <6> So, why doesn't this: <6> (b1 && b2)->(a, &A::callback); <6> ? <4> i'm using std::.. right now :) seems neater <3> Because ->() doesn't mean anything <3> ? <3> Weird that your && returns a pointer <4> yeah i was thinking the same <6> BinaryExpression<Bool, Bool> operator&&(Bool, Bool); <4> ah <3> Or something that overloads -> <6> template<> cl*** BinaryExpression<Bool, Bool> { public: EventServer* operator->(void); }; <6> So, the -> returns an EventServer, and EventServer has defined: <6> void operator()(A&, void(A::*)(void)); <3> Doesn't really matter, it's just a syntax that never worked in C++ <6> So, I'd expect to be able to just use () there. <3> (the ->()) <6> Guess so :( <3> Why not return a reference <6> For what? <6> operator-> ? <3> To replace the -> <6> operator-> has to return a pointer type. I don't understand what you mean. <3> I mean operator* <3> (*(b1 && b2))(a,&A::callback);
<6> (b1 && b2).(a, &A::callback); would be nice, but I can't overload operator. <3> There's also operator EventServer &() but then it needs a cast <6> Maybe this reads better: (b1 && b2) >> (a, &A::callback); <6> heheh <3> So (*(b1 && b2))(a,&A::callback); is not that bad <3> You can also overload , <3> (b1 && b2),(a,&A::callback); <3> Not like it'd work anyway heheh <6> The point is, the last (a,&A::callback) MUST be operator() <3> (*(b1 && b2))(a,&A::callback); <= that's the case here <3> Probably more readable with EventServer & es = *(b1 && b2); es( a, &A::callback ); though <6> Still doesn't really look nice... <3> I'm not sure how two bools can give you an EventServer anyway <3> So syntactically I don't really get it :p <6> The idea is that this call immediately returns, and the callback is called as soon as the expression becomes true (later). <6> Just looking for a nice API now... I'll worry about the implementation later :) <6> Perhaps it's macro time again... <6> WHEN_DO(b1 && b2, a, &A::callback); <6> :) <6> I'd like to have the word 'wait' in it... <6> Hmm. <7> like WaitForSingleObject :) <8> ON_TRUE(exp, a, callback) <6> Wait till b1 && b2, then call (a, &A::callback); <6> Yeah, ON_TRUE is pretty cool. <8> scary concept though <6> I like scary code <3> More ugly than scary <6> What is ugly about it? <3> The part where and'ing bools gives you an event server <6> Well, not really - the anding results in a temporary. <6> The call operator->() does the hard work of creating an event server on the heap, but the event server needs to 'know' the type of the expression (cause it needs to be able to re-evaluate the expression later on) <6> The booleans of the expression each get a boost::shared_ptr to that event server :) <6> Ok, it's ugly. <6> :) <6> But I don't know how else to do it, and still be intuitive. <6> #define ON_TRUE(expr, action) do { (expr)->operator()action; } while(0) <6> ON_TRUE(b1 && b2, (a, &A::callback)); <6> Works for me... <8> are the do and while(0) truely necessay? <9> Asriel yes <6> It's the usual way to create a reasonable safe single statement for a macro. <6> Besides, it won't generate any code. <9> Asriel in case you use it after an if <8> ah <8> yes, I see. Thanks :) <9> it gets rid of the misplaced or dangling else <9> someone had to tell me why several years back <8> I do my utmost to avoid the preprocessor <8> aside from include guards, include and pramga <9> Asriel me also <9> though if do find myself using to w/ ##arg sometimes <9> to output a struct w/ the names of the elements followed by the element value <8> aye, it can be useful <9> but I #undef it as soon as I'm finished w/ the output method <6> On second thought, I'll replace the operator-> with something more verbose... <6> #define ON_TRUE(expr, action...) do { (expr).create_event_server()(action); } while(0) <6> Now I need each Bool to point to the event_server, which is of arbitrary type... And the event server needs to point to each of the Bool objects. <6> So, for a start - I need a common base cl***, say Expression, for the arbitrary typed event server. <6> And the BinaryExpression also needs a template parameter that corresponds to the actual operation of course... AND, OR or XOR. <10> man, i need a husband <10> mowing the lawn is a pita <6> At least you HAVE a lawn <11> Anyone here know much on FireFox's source code? <10> pfft, not worth the trouble <8> no. The mozilla source code is a beast <8> *vastly* more complex than it needs to be/should be <8> with dependancy trees that make the amazon look like a piddly little orchard <11> Yeah I get that impression every time I look at it :/ <11> What I'm really wondering is what FireFox does with it's 20mb of memory <8> mainly run a custom UI library the size of texas <8> though 20 meg for a browser really isn't that bad <11> Does it use GTK?
Return to
#c++ or Go to some related
logs:
#java #chatzone adjustwindowrect ws_overlapped emilia ghinescu si n paleru #AllNiteCafe #AllNiteCafe #skype #linux t #linux
|
|