// I have a code snippet like the following where I'm trying to use C++17 std::variant. auto records = consumer->poll(std::chrono::milliseconds(100)); // poll returns std::vector for (const auto& record : records) { std::variant var(record); } // And I'm getting the following error. consumer.tcc: In instantiation of ‘int Consumer::poll() [with T = myns::MyClass]’: main.cpp:57:23: required from here consumer.tcc:56:39: error: no matching function for call to ‘std::variant::variant(const kafka::ConsumerRecord&)’ 56 | std::variant var(record); | ^~~ /* http://opensource.morganstanley.com/modern-cpp-kafka/doxygen/classKAFKA__API_1_1ConsumerRecord.html */ // So, kafka::ConsumerRecord isn't copyable. So then I tried to move it ... for (auto& record : records) { std::unique_ptr cr(std::move(record)); //std::unique_ptr cr = std::make_unique(record); //std::variant> var(std::move(cr)); } // And got this error ... consumer.tcc:57:42: error: no matching function for call to ‘std::unique_ptr::unique_ptr(std::remove_reference::type)’ 57 | std::unique_ptr cr(std::move(record)); | ^~