Jump to content

  • Log In with Google      Sign In   
  • Create Account

fastcall22

Member Since 04 Feb 2008
Online Last Active Today, 12:30 PM

#5214351 Convenient approach to composite pattern in C++

Posted by fastcall22 on 03 March 2015 - 08:26 PM

template<typename C, typename F>
static inline Caller<C, F> operator->*(C &c, F &&f) {


Yeah, okay. I'm totally okay with what just happened and am totally fine with how readable this is.

static ::operator->*... Yup!


#5214350 Source code with errors: http://ideone.com/eSWKwf

Posted by fastcall22 on 03 March 2015 - 08:16 PM

Okay.

First: Your code was mangled when you copy-pasta'd. Here is the cleaned up code.
Second: You're missing a '#' for the preprocessor directive #define.
Third: In C++, it's usually more pragmatic to use a constant over a macro, but each is acceptable: const int SIZE = 10;
Fourth: You're missing a closing brace for your for loop after line 33.
Fifth: This has nothing to do with "3D" or "game programming" :|


#5213014 Read data from specified adress of memory.

Posted by fastcall22 on 25 February 2015 - 09:26 PM

(I think he's asking why he can't deref a void pointer.)

Then you still need to memcpy, because you cannot what to write without knowing the type, unless you store this information elsewhere:
void do_the_thing(void* write_to, const void* read_from) {
    // Nope!  How many bytes do we write?  What about copy constructors or move constructors?
    // *write_to = read_from;

    // Ok, but dangerous -- you don't know if either are Foobars and you might violate the rule of 3
    memcpy( (char*)write_to, (const char*)read_from, sizeof(Foobar) );

    // Ok, but dangerous -- you don't know if either are actually Foobars
    *reinterpret_cast<Foobar*>(write_to) = *reinterpret_cast<const Foobar*>(read_from);
}

int whatever(const Foobar& foo_a, Foobar& foo_b ) {
    const void* read_from = &foo_a;
    void* write_to = &foo_b;
    
    // sometime later...

    do_the_thing(write_to, read_from);  // Ok, both are Foobars

    const char* str = "Hello there";
    int truth = 47;
    do_the_thing(&str, &truth); // so many levels of wrong
}
EDIT:
This is also assuming that he isn't trying to ReadProcessMemory or WriteProcessMemory.


#5213011 Read data from specified adress of memory.

Posted by fastcall22 on 25 February 2015 - 09:09 PM

He doesn't want to read and write, he wants to read and write.


He doesn't want to "he doesn't want to read and write, he wants to read and write", he wants to "he doesn't want to read and write, he wants to read and write" with variables.


#5212635 Subtraction Problem in Java

Posted by fastcall22 on 24 February 2015 - 12:26 AM

floating point arithmetic anything in Java anything is an approximation


FTFY. Even in math and science, 1.333e0 + 1.333e1 will result in some loss in precision (1.466e1 != 1.4663e0), for four significant digits. Floating point math is no different.

EDIT:
I can't math. sad.png



#5211320 Programmatically search .fla Flash file for imported component

Posted by fastcall22 on 17 February 2015 - 07:29 PM

The problem is that flash files are in binary, and you're attempting to read them as text, which is a big no-no (in the general case). I'm assuming that you are only attempting to identify files having the component and nothing more. If this is the case, then you may be able to use any text editor with a "find all in files" feature.


#5204254 Rendering .obj Model in DirectX 11

Posted by fastcall22 on 14 January 2015 - 12:09 PM

Have you tried turning it on and off again?


#5199652 Boost c++ How to Deserialize Element of Container

Posted by fastcall22 on 23 December 2014 - 01:56 AM

Use an index table.

1. Reserve some space at the beginning of the file for the index table.
2. Serialize each entity, noting the write position of the stream, and store that and the entity ID into the table.
3. After serializing the entities, sort the table by entity ID.
4. Write the number of entities and the contents of the table to the beginning of the file.

When looking for a specific set of entities, all you'll need to do is to read the entire index, binary search for the entity IDs you're looking for, set the read position of the stream, then deserialize the entity. smile.png


#5199218 Chess moves

Posted by fastcall22 on 20 December 2014 - 12:43 AM

That is very disappointing. I guess I'll have to find some other programmer use for a 5TB external hard drive.

Oh, I know!! How about...

...

...
 
Spoiler



#5199041 C++ how to declare something that isn't declared?!?

Posted by fastcall22 on 18 December 2014 - 07:48 PM

Oberon:
It's not.

My guess is that WiredCat is trying to follow Borland convention or Pascal convention...


#5196679 Does ImageIO.read work in Java applets?

Posted by fastcall22 on 06 December 2014 - 02:20 PM

"Java applet"? What year is it??


#5195611 Crash with <unable to read memory> error

Posted by fastcall22 on 30 November 2014 - 09:09 PM

Check the object you're calling on; it could be null or invalid.


#5195610 *. not the same as ->

Posted by fastcall22 on 30 November 2014 - 09:04 PM

struct Foobar {
    int member;
};

int main() {
    Foobar f = {2};
    Foobar* ptr = &f;

    return (*ptr).member == ptr->member && ptr->member == f.member;
}
Hmm?


#5184826 Quaternion camera flipping constantly

Posted by fastcall22 on 03 October 2014 - 02:12 PM

I had a similar problem in the past. The problem was that I assumed quat::fromRotation(ang,x,y,z) == quat(ang,x,y,z), which isn't true. See Axis Angle to Quaternion.


#5184375 This chat, apparently, is a gigantic coding horror

Posted by fastcall22 on 01 October 2014 - 11:57 AM

Okay, dsm, I'm sorry for flying off the handle. I just got frustrated because you weren't understanding Unicode and/or HTML.
Anyways, it's not technically a blank line in much the same way " " isn't blank line. The difference is that the latter isn't allowed because it's recognized as just spaces, whereas the former is allowed, because it doesn't recgonize &​#x200B; as a non-printable character.




PARTNERS