1

Topic: Resolution of overload VC ++ 15.5.4

The code ceased to work after the last update of studio to version 15.5.4 more low. Checked up on http://rextester.com VC still compiles, GCC is not present. Probably earlier VC was not it is right. How correctly to write such overload? #include <iostream> template <typename L, typename R> void (max) (L const& a, R const& b) {std:: cout <<"void (max) (L const& a, R const& b)" <<std:: endl;} template <typename M> void (max) (typename M:: value_type scalar, M const& a) {std:: cout <<"void (max) (typename M:: value_type scalar, M const& a)" <<std:: endl;} template <typename T, typename U> struct EmptyBase {typedef T value_type; typedef U this_type;}; template <typename T> struct Matrix: public EmptyBase <T, Matrix <T>> {}; int main () {Matrix <double> m; double s; max (s, m); std:: cout <<"Hello, world! \n";} p.s. A variant void (max) (double scalar, M const& a) not to offer

2

Re: Resolution of overload VC ++ 15.5.4

Hello, Kazmerchuk Pavel, you wrote: KP> the Code ceased to work after the last update of studio to version 15.5.4 more low. KP> Checked up on http://rextester.com VC still compiles, GCC is not present. Probably earlier VC was not it is right. KP> how correctly to write such overload? KP> p.s. A variant void (max) (double scalar, M const& a) not to offer Well it is standard: https://ideone.com/VeIg1I #include <iostream> template <typename, typename, typename = void> struct Max; template <typename L, typename R> void (max) (L const& a, R const& b) {Max <L, R> () (a, b);} template <typename L, typename R, typename> struct Max {void operator () (L const& a, R const& b) const {std:: cout <<"void (max) (L const& a, R const& b)" <<std:: endl;} }; template <typename M> struct Max <typename M:: value_type, M> {void operator () (typename M:: value_type scalar, M const& a) const {std:: cout <<"void (max) (typename M:: value_type scalar, M const& a)" <<std:: endl;}}; template <typename T, typename U> struct EmptyBase {typedef T value_type; typedef U this_type;}; template <typename T> struct Matrix: public EmptyBase <T, Matrix <T>> {}; int main () {Matrix <double> m; double s; max (s, m); max (s, 42); std:: cout <<"Hello, world! \n";}

3

Re: Resolution of overload VC ++ 15.5.4

Hello, rg45, you wrote: R> Well it is standard: Thanks! Thought all the same it is possible to manage somehow an overload. So it was beautiful...

4

Re: Resolution of overload VC ++ 15.5.4

At first, what for you bracket names of functions? Secondly, for example here so: #include <iostream> #include <utility> template <class T, class E = void> struct has_value_member: std:: false_type {}; template <class T> struct has_value_member <T, std:: void_t <typename T:: value_type>>: std:: true_type {}; template <typename L, typename R> std::enable_if_t<!has_value_member<R>::value> max (L const& a, R const& b) {std:: cout <<"void (max) (L const& a, R const& b)" <<std:: endl;} template <typename M> std::enable_if_t<has_value_member<M>::value> max (typename M:: value_type scalar, M const& a) {std:: cout <<"void (max) (typename M:: value_type scalar, M const& a)" <<std:: endl;} template <typename T, typename U> struct EmptyBase {typedef T value_type; typedef U this_type;} ; template <typename T> struct Matrix: public EmptyBase <T, Matrix <T>> {}; const bool has = has_value_member <Matrix <double>>:: value; const bool hasnot = has_value_member <char>:: value; int main () {Matrix <double> m; double s; max (s, m); char* a, *b; max (a, b); std:: cout <<"Hello, world! \n";}