Я использую C++ std11 и я имею следующий кодстанд :: unique_ptr <Mesh> :: unique_ptr (__ gnu_cxx :: __ alloc_traits <станд :: распределителем <Mesh>> :: value_type &)»
#include "RenderEngine.h"
#include "Cam.h"
#include "Vec3d.h"
#include "Mesh.h"
#include "Model.h"
#include <vector>
#include <memory>
struct Option
{
int imageWidth, imageHeight;
};
int main()
{
Cam* cam = new Cam(Vec3d(0.0, 0.0, 250.0), Vec3d(0.0, 0.0, -1.0), 90, 1);
//Cam* cam = new Cam();
Option option;
option.imageWidth = 1920;
option.imageHeight = 1080;
//option.imageWidth = 1280;
//option.imageHeight = 900;
Model myModel;
myModel.loadModel("/models/arm.obj");
std::vector<std::unique_ptr<Mesh>> objects;
std::unique_ptr<Mesh> myMesh(myModel.meshes[0]);
objects.push_back(std::move(myMesh));
RenderEngine* render = new RenderEngine(*cam, option.imageWidth, option.imageHeight);
render->getImage(objects);
delete cam;
delete render;
return 0;
}
с моим класс Model
, которые содержат std::vector<Mesh> meshes
;
, когда я скомпилировать этот код, я следующая ошибка:
[email protected]:~/Documenti/C++/Progetti_POG/002_Beta$ make
g++ -Wall -c -g -std=c++11 testRender.cpp -o obj/testRender.o -Llib
testRender.cpp: In function ‘int main()’:
testRender.cpp:27:50: error: no matching function for call to ‘std::unique_ptr<Mesh>::unique_ptr(__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type&)’
std::unique_ptr<Mesh> myMesh(myModel.meshes[0]);
^
testRender.cpp:27:50: note: candidates are:
In file included from /usr/include/c++/4.8/memory:81:0,
from RenderEngine.h:13,
from testRender.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:176:2: note: template<class _Up, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::auto_ptr<_Up>&&)
unique_ptr(auto_ptr<_Up>&& __u) noexcept;
^
/usr/include/c++/4.8/bits/unique_ptr.h:176:2: note: template argument deduction/substitution failed:
testRender.cpp:27:50: note: ‘__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type {aka Mesh}’ is not derived from ‘std::auto_ptr<_Up>’
std::unique_ptr<Mesh> myMesh(myModel.meshes[0]);
^
In file included from /usr/include/c++/4.8/memory:81:0,
from RenderEngine.h:13,
from testRender.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:169:2: note: template<class _Up, class _Ep, class> std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Up, _Ep>&&)
unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
^
/usr/include/c++/4.8/bits/unique_ptr.h:169:2: note: template argument deduction/substitution failed:
testRender.cpp:27:50: note: ‘__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type {aka Mesh}’ is not derived from ‘std::unique_ptr<_Tp, _Dp>’
std::unique_ptr<Mesh> myMesh(myModel.meshes[0]);
^
In file included from /usr/include/c++/4.8/memory:81:0,
from RenderEngine.h:13,
from testRender.cpp:1:
/usr/include/c++/4.8/bits/unique_ptr.h:160:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = Mesh; _Dp = std::default_delete<Mesh>]
unique_ptr(unique_ptr&& __u) noexcept
^
/usr/include/c++/4.8/bits/unique_ptr.h:160:7: note: no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type {aka Mesh}’ to ‘std::unique_ptr<Mesh>&&’
/usr/include/c++/4.8/bits/unique_ptr.h:157:17: note: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr(std::nullptr_t) [with _Tp = Mesh; _Dp = std::default_delete<Mesh>; std::nullptr_t = std::nullptr_t]
constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
^
/usr/include/c++/4.8/bits/unique_ptr.h:157:17: note: no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type {aka Mesh}’ to ‘std::nullptr_t’
/usr/include/c++/4.8/bits/unique_ptr.h:151:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::remove_reference<_To>::type&&) [with _Tp = Mesh; _Dp = std::default_delete<Mesh>; std::unique_ptr<_Tp, _Dp>::pointer = Mesh*; typename std::remove_reference<_To>::type = std::default_delete<Mesh>]
unique_ptr(pointer __p,
^
/usr/include/c++/4.8/bits/unique_ptr.h:151:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.8/bits/unique_ptr.h:146:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer, typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type) [with _Tp = Mesh; _Dp = std::default_delete<Mesh>; std::unique_ptr<_Tp, _Dp>::pointer = Mesh*; typename std::conditional<std::is_reference<_Dp>::value, _Dp, const _Dp&>::type = const std::default_delete<Mesh>&]
unique_ptr(pointer __p,
^
/usr/include/c++/4.8/bits/unique_ptr.h:146:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.8/bits/unique_ptr.h:141:7: note: std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = Mesh; _Dp = std::default_delete<Mesh>; std::unique_ptr<_Tp, _Dp>::pointer = Mesh*]
unique_ptr(pointer __p) noexcept
^
/usr/include/c++/4.8/bits/unique_ptr.h:141:7: note: no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<Mesh> >::value_type {aka Mesh}’ to ‘std::unique_ptr<Mesh>::pointer {aka Mesh*}’
/usr/include/c++/4.8/bits/unique_ptr.h:135:17: note: constexpr std::unique_ptr<_Tp, _Dp>::unique_ptr() [with _Tp = Mesh; _Dp = std::default_delete<Mesh>]
constexpr unique_ptr() noexcept
^
/usr/include/c++/4.8/bits/unique_ptr.h:135:17: note: candidate expects 0 arguments, 1 provided
make: *** [obj/testRender.o] Errore 1
пожалуйста, я не понимаю, где это ошибка, я имею вектор Mesh
и использовать operator[]
Подари мне Mesh
и с этим i creat a unique_ptr<Mesh>
Спасибо.
PS. те мой класс:
#ifndef _MODEL_H
#define _MODEL_H
#include "Mesh.h"
#include <vector>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class Model
{
public:
std::vector<Mesh> meshes;
std::string directory;
void loadModel(std::string path);
void processNode(aiNode* node, const aiScene* scene);
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
};
#endif
#ifndef _MESH_H
#define _MESH_H
#include "Vec3d.h"
#include "Ray.h"
#include <vector>
class Mesh
{
protected:
unsigned int numVertices, numFaces;
std::vector<unsigned int> vertexIndex;
std::vector<Vec3d> verts;
std::vector<Vec3d> vertexNormals;
Vec3d cl;
public:
Mesh(unsigned int &_numVertices, unsigned int &_numFaces, std::vector<unsigned int> &_vertexIndex, std::vector<Vec3d> &_verts, std::vector<Vec3d> &_vertexNormals);
bool intersect(Ray &r, double &t, double &u, double &v);
inline const Vec3d getCL(){ return cl; }
};
#endif
это дает мне ошибку: 'make_unique' не входит в группу 'std' –
Включите (-а)? –
Да, это в комплекте –