Sign in to follow this  
f8k8

Rimpl

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this