问题
I am currently playing around with openscenegraph and it uses its own smart pointer. But I want to use the std c++11 smart pointer.
now this is the working example code
osg::ref_ptr<osg::Uniform> SineUniform = new osg::Uniform( "Sine", 0.0f );
but when I do something like this
std::unique_ptr<osg::Uniform> SineUniform = new osg::Uniform( "Sine", 0.0f );
Then I get the following error message
error: conversion from 'osg::Uniform*' to non-scalar type 'std::unique_ptr' requested
Any idea what is going on? Are there some requirements for smart pointers?
回答1:
You should do this:
std::unique_ptr<osg::Uniform> SineUniform(new osg::Uniform( "Sine", 0.0f ));
Also, be careful not to mix different types of smart pointers. OpenSceneGraph may make assumptions on how its objects are managed, and may require using osg::ref_ptr
instead. You should go through the documentation to find this out - I cannot help with that unfortunately.
来源:https://stackoverflow.com/questions/16364637/conversion-to-non-scalar-type-with-std-c11-smart-pointer