"Could not deduce template argument" error when using Winsock bind() call with Boost
By : user1845987
Date : March 29 2020, 07:55 AM

Deduce template argument from std::function call signature
By : Rodolphe LOUISSIDNE
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Consider this template function: code :
std::function<bool()> bar;
foo(bar); // works just fine

Could not deduce (Eq a) from (Num a) or from (Floating a). But Can deduce (Eq a) from (Integral a). Why?
By : Bernard Gressing
Date : March 29 2020, 07:55 AM
seems to work fine Short answer Because that's the definition of Num in the prelude: code :
class Num a where
...
class (Real a, Enum a) => Integral a where
...
class (Num a, Ord a) => Real a where
...
class Eq a => Ord a where
...
newtype Sequence = Sequence (Integer > Integer)
instance Num Sequence where
(Sequence x) + (Sequence y) = Sequence $ \pt > x pt + y pt
(Sequence x)  (Sequence y) = Sequence $ \pt > x pt  y pt
(Sequence x) * (Sequence y) = Sequence $ \pt > x pt * y pt
negate (Sequence x) = Sequence $ \pt > pt
abs (Sequence x) = Sequence $ \pt > abs pt
signum (Sequence x) = Sequence $ \pt > signum pt
fromInteger = Sequence . const
 Ignore the fact that you'd implement these methods using Applicative.
instance Eq Sequence where
 This will never return True, ever.
(Sequence x) == (Sequence y) =
and [x pt == y pt  pt < [0..]] &&
and [x pt == y pt  pt < [1,2..]]

Deduce template parameter pack from function call
By : user3654520
Date : March 29 2020, 07:55 AM
This might help you Template deduction is not possible, but maybe you can restructure your code in a way that MyClass defines the all necessary types and then you have a check function that takes MyClass as a template argument. That way, the checking function has access to all the necessary types. code :
template <typename... Types> struct OtherClass {};
template <typename... Types>
struct MyClass
{
typedef OtherClass<Types...> OtherClass_t;
typedef int result_t;
enum SomeEnum { value0 = 1 };
};
// version 1
template < typename C >
struct Checker {
typename C::result_t operator()(typename C::SomeEnum value)
{
typename C::OtherClass_t obj;
typename C::result_t result;
// calculate result from obj;
return result;
}
};
// version 2
template < typename C >
typename C::result_t check_fun(typename C::SomeEnum value)
{
typename C::OtherClass_t obj;
typename C::result_t result;
// calculate result from obj;
return result;
}
int main() {
typedef MyClass< int, bool > myclass_t;
auto value = myclass_t::value0;
// ...
Checker< myclass_t > check;
int t = check(value);
auto s = check_fun<myclass_t>(value);
}

how to deduce the size of a multidimensional array in a curly brace expression of a function call with templates
By : J. Lu
Date : March 29 2020, 07:55 AM
around this issue You cannot deduce multi dimensional array bounds from nested {{}}. You could deduce it by adding some tokens. code :
using namespace std;
auto arr = array{ array{1,2}, array{3,4} };
for (auto row : arr) {
for (auto e : row) {
std::cout << e << ",";
}
std::cout << "\n";
}
make_tensor(a{a{1,2},a{3,4}})
tensor{ tensor{1,2}, tensor{1,2} }

