3

I am currently refactoring some old code to meet C++14 standards of correctness and something weird is happening.

This error is so far unique and does not appear in the rest of the code. I've obfuscated the actual types because they aren't important.

Prior to the refactor, the following code worked just fine:

namespace N {
    class A {
    public:
        A(B* blah) : _blah(blah); //class A owns the instance of class B.
        ~A() { delete m_blah; m_blah = nullptr; }
        //...Lots more code.
    private:
        B* m_blah;
    };
}

I changed any necessary ownership-based pointers to their respective smart pointers:

#include <memory>

namespace N {
    class A {
    public:
        A(std::unique_ptr<B> blah);
        ~A() { /* DO NOTHING */ }
    private:
        std::unique_ptr<B> m_blah;
    };
}

This no longer works. Intellisense reports an error:

"Error: namespace "N::std" has no member unique_ptr"

in the constructor declaration. (But NOT the declaration of m_blah)

....What? Why is the standard library namespace being pulled into N?!

Versioning Info:

  • VS2015 Community Edition (RTM) Version 14.0.23107.0 D14REL
  • Developer Command Prompt reports cl version: Compiler Version 19.00.23026
Casey
  • 10,297
  • 11
  • 59
  • 88

1 Answers1

0

I booted up VS this morning and the problem disappeared on its own.

In an attempt to make sure I can isolate any future problems and since the code base is massive I went back to square one to see if I could prevent the error:

  • Excluded all code files from the project not related to the problem.
  • Commented out code in related files that was not directly related to the problem.
  • Rewrote the class in a minimal context (using smart pointers).

So far, so good.

Casey
  • 10,297
  • 11
  • 59
  • 88