plugin_vc (and other plugins, probably) failed to compile on /std:c++latest on my system because of these errors:
1>C:\Users\overanalytcl\plugin-sdk\shared\Pattern.h(33,1): error C2440: 'initializing': cannot convert from 'hook::pattern' to 'hook::pattern &'
1>C:\Users\overanalytcl\plugin-sdk\shared\Pattern.h(33,25): message : A non-const reference may only be bound to an lvalue
1>C:\Users\overanalytcl\plugin-sdk\shared\Pattern.h(54,1): error C2440: 'initializing': cannot convert from 'hook::pattern' to 'hook::pattern &'
1>C:\Users\overanalytcl\plugin-sdk\shared\Pattern.h(54,25): message : A non-const reference may only be bound to an lvalue
1>C:\Users\overanalytcl\plugin-sdk\shared\SpriteLoader.cpp(174,40): error C2440: 'initializing': cannot convert from 'std::_List_iterator<std::_List_val<std::_List_simple_types<_Ty>>>' to 'std::_List_iterator<std::_List_val<std::_List_simple_types<_Ty>>> &'
1> with
1> [
1> _Ty=std::pair<const std::string,plugin::texClass *>
1> ]
1>C:\Users\overanalytcl\plugin-sdk\shared\SpriteLoader.cpp(174,17): message : A non-const reference may only be bound to an lvalue
This PR attempts to solve that. In Pattern.h's case, ..\hooking\Hooking.Patterns.h has:
and auto is deduced as basic_pattern<assert_err_policy> which is not a reference.
In SpriteLoader's case, in https://en.cppreference.com/w/cpp/language/auto it says that the type deduction for auto is ruled by the same rules as template argument deduction: https://en.cppreference.com/w/cpp/language/template_argument_deduction. C++ has a feature to extend the lifetime of an object if it's bound to a const auto&, thus it works for both lvalues and rvalues (temporary variables). Even if you could do something like auto&&, we're not changing s, thus it's a perfectly sensible choice.
Edit: seems like Github is confused about the commit author, ignore that aspect.
plugin_vc (and other plugins, probably) failed to compile on /std:c++latest on my system because of these errors:
This PR attempts to solve that. In
Pattern.h
's case,..\hooking\Hooking.Patterns.h
has:which calls:
and auto is deduced as
basic_pattern<assert_err_policy>
which is not a reference.In SpriteLoader's case, in https://en.cppreference.com/w/cpp/language/auto it says that the type deduction for auto is ruled by the same rules as template argument deduction: https://en.cppreference.com/w/cpp/language/template_argument_deduction. C++ has a feature to extend the lifetime of an object if it's bound to a
const auto&
, thus it works for both lvalues and rvalues (temporary variables). Even if you could do something likeauto&&
, we're not changings
, thus it's a perfectly sensible choice.Edit: seems like Github is confused about the commit author, ignore that aspect.