Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] weird pointer issue  (Read 2351 times)

0 Members and 1 Guest are viewing this topic.

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
[Solved] weird pointer issue
« on: January 07, 2014, 07:18:08 am »
Recently for my project I made the switch from VS 2010 to VS 2012 to take advantage of some of the newer features it offers, but I've seem to run into an interesting issue I can't seem to figure out.

Currently right now I am trying to build the TextureHolder from the sfml game dev book
namespace Textures
{
        enum ID
        {
                Skeleton
        };
}

class TextureHolder
{
public:
        void Load(Textures::ID id, const std::string& filename);
        sf::Texture& Get(Textures::ID id);
        const sf::Texture& Get(Textures::ID id) const;

private:
        std::map<Textures::ID, std::unique_ptr<sf::Texture>> mTextureMap;
};
 

Pretty Straight forward stuff. But on use I get this error:
error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>.

So I investigated this little issue, which appears that the pairing of the std::map is trying to copy over the unique_ptr, which is illegal. I looked into this but couldn't find one single answer as to what was going on. Apparently the issue might be my compiler using old libs? I have tried full uninstalls/re-installs, full repairs, creating a new Empty Project and bringing in all my files individually - everything I can think of.

I've exhausted my resources so now I turn to all of you...  I hope one of you has an answer.
Also I would give you all a complete and minimal example, but I believe this to be a compiler issue... but I could be completely wrong, who knows.
« Last Edit: January 08, 2014, 02:51:34 am by Gobbles »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: weird pointer issue
« Reply #1 on: January 07, 2014, 08:00:26 am »
Since this is an issue of using the object, could you show the code, where you use it.

If it's not your mistake, but a compiler issue, it should be very easy to create a minimal example. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: weird pointer issue
« Reply #2 on: January 07, 2014, 09:38:54 am »
if it is a compiler issue, you may write minimal example that use's it
if you've got error, it means an issue but if not, it seam's your code has problem
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: weird pointer issue
« Reply #3 on: January 07, 2014, 03:40:44 pm »
I'll post my useage of the object and whip up a an example when I get home from work. However I am certain using the github code for the book will produce the same results. I'll test all this as soon as I can.

amir ramezani

  • Jr. Member
  • **
  • Posts: 81
  • i'm a programmer who can't see well
    • View Profile
    • download useful software!
    • Email
Re: weird pointer issue
« Reply #4 on: January 07, 2014, 07:13:25 pm »
try GCC with Codeblocks and see what happen's?
because I haven't used MSVC to develop games and my Operating System
if you can't see well, you can't test your applications and operating system well
my game engine:
allegro game creator
my operating system:
AmirOS

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: weird pointer issue
« Reply #5 on: January 07, 2014, 08:45:19 pm »
try GCC with Codeblocks and see what happen's?
because I haven't used MSVC to develop games and my Operating System

Microsoft VS 11/2012 and 12/2013 work fine with the SFML Game Development book.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Gobbles

  • Full Member
  • ***
  • Posts: 132
    • View Profile
    • Email
Re: weird pointer issue
« Reply #6 on: January 08, 2014, 02:39:32 am »
Ok so I figured out the issue, quite the slap in the face once I did.

Originally I stored my character in a std::shared_ptr, for whatever reason I have no idea.. but I did, anyways this conflicts with the use of std::unique_ptr's inside of vectors and maps(within the character), but not standalone std::unique_ptr's, which is quite curious. I'll have to read up more on why this is. Switching pointers cleaned up the issue.