Jump to content
  • Advertisement
Sign in to follow this  
wasd

Rimpl

This topic is 3506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've currently got my class implementations stored in a private implementation class for things in my engine, so that the interface is constant, but I can change the implementation for different platforms. The problem at the moment is that the implementations are simply members, not pointers, so that the interface classes need to include the platform specific implementation headers. I'd like to change over to a proper pimpl, but I've come across the rimpl idiom, which stores a reference to the implementation, instead of a pointer. Has anyone used this, or does everyone stick with just having a pointer? The only advantage really is that it gets rid of a level of indirection, but at the cost of not being able to allow the assignment operator, as references can only be assigned in constructors. Though I think I may have figured out a way around this, using a nasty placement new hack, which just seems really messy :) Really, I was just wondering if anyone has used the pimpl idiom but with references instead of pointers, and if there's some easy way of doing it.

Share this post


Link to post
Share on other sites
Advertisement
If you do not use a pointer you lose the assignment operator - as you mentioned - but you also lose polymorphism. So, you won't be able to switch out implementations at run-time, such as changing renderer from DX to OGL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!