Closed heilkn closed 4 years ago
Would you mind if I ask you to provide lesser code snippet (at least which is not using any external APIs)? I feel eager to fix that, but with the example you'd provided it is hard to reproduce the problem.
@heilkn do you still experience the problem? Could you provide simplified code snippet?
I am sorry for the delay. I will create a shorter example.
Kind regards
Konstantin
From: kchernik notifications@github.com Sent: Monday, 14 October 2019 16:28 To: boost-experimental/di Cc: Konstantin Heil; Mention Subject: Re: [boost-experimental/di] Adding default Destructor breaks Compilation (#428)
@heilkn do you still experience the problem? Could you provide simplified code snippet?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Ok, I removed as much as I could and the problem seems to be the unique_ptr member. For me, compilation stops working with visual studio 2017 when uncommenting the defaulted destructor. I am sorry, for not taken the time to create the minimal example in the first place.
#include "di.hpp"
namespace di = boost::di;
#include <memory>
#include <tuple>
class Instance {
public:
Instance
() {}
//~Instance() = default;
private:
std::unique_ptr<int> _handle;
};
using Application = std::tuple
< Instance
>;
int main(int, char**)
{
auto app = di::make_injector
( ).create<Application>();
return 0;
}
Your issues has nothing to do with boost di.
The problem is defining a destructor cause removal of implicitly generated move constructor (as well as copy but in your case std::unique
has already took care of it)
You can check and see the same result:
Application app;
auto app1 = move(app);
You can easily fix it by providing move constructor. Instance(Instance&& other) noexcept = default;
A couple of links:
Thank you very much for the response. In that case a nicer error message would have been useful for why the type did not satisfy the creatable constraint. I thought adding the generated destructor explicitly does not change anything.
Also, it would be really nice if one could construct non-copyable, non-movable types.
Hello, thank you for your work on this promising and interesting library. As I have already mentioned in another thread I am evaluating and exploring this library a little bit.
For the following code uncommenting the default destructor for vulkan::Instance breaks compilation with the error attached at the bottom of this message.
I used version 1.1.0