문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top