#include <iostream>
#include <unordered_map>
#include <string>
#include <memory>
typedef struct {
int a;
} data_t;
using datap_t = std::unique_ptr<data_t>;
using MyMap = std::unordered_map<std::string, datap_t>;
using MyPair = std::pair<std::string, datap_t>;
int main() {
data_t * pd1 = new data_t();
MyPair p("tst", pd1);
// MyPair p("tst", datap_t(pd1)); // Works
// data_t * pd2 = new data_t();
// MyMap m;
//m.emplace("e1", pd2);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dW5vcmRlcmVkX21hcD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPG1lbW9yeT4KCnR5cGVkZWYgc3RydWN0IHsKICAgIGludCBhOwp9IGRhdGFfdDsKCnVzaW5nIGRhdGFwX3QgPSBzdGQ6OnVuaXF1ZV9wdHI8ZGF0YV90PjsKdXNpbmcgTXlNYXAgPSBzdGQ6OnVub3JkZXJlZF9tYXA8c3RkOjpzdHJpbmcsIGRhdGFwX3Q+Owp1c2luZyBNeVBhaXIgPSBzdGQ6OnBhaXI8c3RkOjpzdHJpbmcsIGRhdGFwX3Q+OwoKaW50IG1haW4oKSB7CiAgICBkYXRhX3QgKiBwZDEgPSBuZXcgZGF0YV90KCk7CiAgICBNeVBhaXIgcCgidHN0IiwgcGQxKTsKICAgIC8vIE15UGFpciBwKCJ0c3QiLCBkYXRhcF90KHBkMSkpOyAvLyBXb3JrcwoKICAgIC8vIGRhdGFfdCAqIHBkMiA9IG5ldyBkYXRhX3QoKTsKICAgIC8vIE15TWFwIG07CiAgICAvL20uZW1wbGFjZSgiZTEiLCBwZDIpOwogICAgCiAgICByZXR1cm4gMDsKfQo=
prog.cpp: In function 'int main()':
prog.cpp:16:24: error: no matching function for call to 'std::pair<std::basic_string<char>, std::unique_ptr<data_t> >::pair(const char [4], data_t*&)'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:206:9: note: candidate: template<class ... _Args1, unsigned int ..._Indexes1, class ... _Args2, unsigned int ..._Indexes2> std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>)
pair(tuple<_Args1...>&, tuple<_Args2...>&,
^
/usr/include/c++/5/bits/stl_pair.h:206:9: note: template argument deduction/substitution failed:
prog.cpp:16:24: note: mismatched types 'std::tuple<_Elements ...>' and 'const char [4]'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:155:9: note: candidate: template<class ... _Args1, class ... _Args2> std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>)
pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
^
/usr/include/c++/5/bits/stl_pair.h:155:9: note: template argument deduction/substitution failed:
prog.cpp:16:24: note: cannot convert '"tst"' (type 'const char [4]') to type 'std::piecewise_construct_t'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:150:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&)
constexpr pair(pair<_U1, _U2>&& __p)
^
/usr/include/c++/5/bits/stl_pair.h:150:12: note: template argument deduction/substitution failed:
prog.cpp:16:24: note: mismatched types 'std::pair<_T1, _T2>' and 'const char [4]'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:144:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&)
constexpr pair(_U1&& __x, _U2&& __y)
^
/usr/include/c++/5/bits/stl_pair.h:144:12: note: template argument deduction/substitution failed:
/usr/include/c++/5/bits/stl_pair.h:141:38: error: no type named 'type' in 'struct std::enable_if<false, void>'
template<class _U1, class _U2, class = typename
^
/usr/include/c++/5/bits/stl_pair.h:138:12: note: candidate: template<class _U2, class> constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&)
constexpr pair(const _T1& __x, _U2&& __y)
^
/usr/include/c++/5/bits/stl_pair.h:138:12: note: template argument deduction/substitution failed:
/usr/include/c++/5/bits/stl_pair.h:136:27: error: no type named 'type' in 'struct std::enable_if<false, void>'
template<class _U2, class = typename
^
/usr/include/c++/5/bits/stl_pair.h:133:12: note: candidate: template<class _U1, class> constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)
constexpr pair(_U1&& __x, const _T2& __y)
^
/usr/include/c++/5/bits/stl_pair.h:133:12: note: template argument deduction/substitution failed:
prog.cpp:16:24: note: cannot convert 'pd1' (type 'data_t*') to type 'const std::unique_ptr<data_t>&'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:128:17: note: candidate: constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>&&) [with _T1 = std::basic_string<char>; _T2 = std::unique_ptr<data_t>]
constexpr pair(pair&&) = default;
^
/usr/include/c++/5/bits/stl_pair.h:128:17: note: candidate expects 1 argument, 2 provided
/usr/include/c++/5/bits/stl_pair.h:124:12: note: candidate: template<class _U1, class _U2, class> constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&)
constexpr pair(const pair<_U1, _U2>& __p)
^
/usr/include/c++/5/bits/stl_pair.h:124:12: note: template argument deduction/substitution failed:
prog.cpp:16:24: note: mismatched types 'const std::pair<_T1, _T2>' and 'const char [4]'
MyPair p("tst", pd1);
^
In file included from /usr/include/c++/5/bits/stl_algobase.h:64:0,
from /usr/include/c++/5/bits/char_traits.h:39,
from /usr/include/c++/5/ios:40,
from /usr/include/c++/5/ostream:38,
from /usr/include/c++/5/iostream:39,
from prog.cpp:1:
/usr/include/c++/5/bits/stl_pair.h:112:26: note: candidate: constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = std::basic_string<char>; _T2 = std::unique_ptr<data_t>]
_GLIBCXX_CONSTEXPR pair(const _T1& __a, const _T2& __b)
^
/usr/include/c++/5/bits/stl_pair.h:112:26: note: no known conversion for argument 2 from 'data_t*' to 'const std::unique_ptr<data_t>&'
/usr/include/c++/5/bits/stl_pair.h:108:26: note: candidate: constexpr std::pair<_T1, _T2>::pair() [with _T1 = std::basic_string<char>; _T2 = std::unique_ptr<data_t>]
_GLIBCXX_CONSTEXPR pair()
^
/usr/include/c++/5/bits/stl_pair.h:108:26: note: candidate expects 0 arguments, 2 provided