When you try to call wil::reg::set_value with an std::wstring argument you get a compiler error.
e.g.:
std::wstring my_value = L"Hello";
wil::reg::set_value(HKEY_CURRENT_USER, L"Software\\MyApp", L"MyValue", my_value);
results in:
static_assert failed: 'Unsupported type for set_value_type'
The issue seems to be that reg_view_t::set_value deduces the argument type as const R& value, which will always be the non-const version:
|
template <typename R> |
|
typename err_policy::result set_value( |
|
_In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, const R& value, DWORD type = reg_value_type_info::set_value_type<R>()) const |
|
{ |
|
return set_value_with_type(subkey, value_name, value, type); |
|
} |
It then passes R to reg_value_type_info::set_value_type<R>, but this expects the const version:
|
template <> |
|
constexpr DWORD set_value_type<const ::std::wstring>() WI_NOEXCEPT |
|
{ |
|
return REG_SZ; |
|
} |
This probably means that all other smart string variants listed there are also affected.
I think the best approach to fix this would be to switch all the affected set_value_type specializations to non-const.
When you try to call
wil::reg::set_valuewith anstd::wstringargument you get a compiler error.e.g.:
results in:
The issue seems to be that
reg_view_t::set_valuededuces the argument type asconst R& value, which will always be the non-const version:wil/include/wil/registry_helpers.h
Lines 1182 to 1187 in 3ecba60
It then passes
Rtoreg_value_type_info::set_value_type<R>, but this expects theconstversion:wil/include/wil/registry_helpers.h
Lines 1008 to 1012 in 3ecba60
This probably means that all other smart string variants listed there are also affected.
I think the best approach to fix this would be to switch all the affected
set_value_typespecializations to non-const.