Hello All
My apologies in advance if my question is out of line (or just plain stupid). Or has already been answered (couldn't find it if so).
I am an experienced programmer, but somewhat of a newbie as regards C++ and OSG.
A code snippet noting my question:
osg::ref_ptr<osg::GraphicsContext::Traits> pclsTraits;
pclsTraits = new osg::GraphicsContext::Traits(); //<<<<<<<<
//pclsTraits = osg::ref_ptr<osg::GraphicsContext::Traits>();
//pclsTraits = std::make_unique<osg::GraphicsContext::Traits>();
pclsTraits->inheritedWindowData = new osgViewer::GraphicsWindowWin32::WindowData(hWnd);
pclsTraits->setInheritedWindowPixelFormat = true;
pclsTraits->doubleBuffer = true;
pclsTraits->windowDecoration = true;
pclsTraits->sharedContext = nullptr;
pclsTraits->supportsResize = true;
<pulled from a cookbook example I found>
My compiler (Visual Studio 2019 Ver. 16.11.1) emits warning C26409 on the line noted with <<<<<, saying that I should avoid calling new explicitly, instead suggesting that I use std::make_unique<T> instead.
When I tried that (see the 2nd commented line) the compiler emits an error saying: 'no operator "=" matches these operands'.
When I tried what was shown in the 1st commented line, it compiled fine with no warnings or errors but threw an exception when ran.
The code using the 'new' keyword works flawlessly.
What I am trying to do is make use of OSG's ref_ptrs but at the same time keep my compiler happy and minimize the warnings it emits. I don't seem to be smart enough to make that happen.
Is there a modification to this code snippet that lets me set up a ref_ptr without using the keyword 'new'?
Thanks in advance,
Bob Kiser