What is the better usage ?
There is a problem with templates in the current design.
How it can be solved ?
1.a.
Some macros:
template<typename T>
void f(param int in a, param int out b)
<i>// void f(::boost::call_traits< int >::param_type a, ::boost::call_traits< int >::reference b)</i>
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(i, j);
1.b.
Or maybe
template<typename T>
void f(param<int>in a, param<int>out b)
<i>// void f(::boost::call_traits <int> ::param_type a, ::boost::call_traits <int> ::reference b)</i>
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(i, j);
2.a.
Some templates:
template<typename T>
void f(in_<T> a, out_<T> b)
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(in(i), out(j));
2.b.
Or maybe with some macro:
Some templates:
template<typename T>
void f(in_<T> a, out_<T> b)
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(in i, out j);
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It would be better if you rename the "out" parameter to "in_out" or "reference". C++ has only one "out", it is a function result. C# and COM have "out" parameters.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What is the better usage ?
There is a problem with templates in the current design.
How it can be solved ?
1.a.
Some macros:
template<typename T>
void f(param int in a, param int out b)
<i>// void f(::boost::call_traits< int >::param_type a, ::boost::call_traits< int >::reference b)</i>
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(i, j);
1.b.
Or maybe
template<typename T>
void f(param<int>in a, param<int>out b)
<i>// void f(::boost::call_traits <int> ::param_type a, ::boost::call_traits <int> ::reference b)</i>
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(i, j);
2.a.
Some templates:
template<typename T>
void f(in_<T> a, out_<T> b)
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(in(i), out(j));
2.b.
Or maybe with some macro:
Some templates:
template<typename T>
void f(in_<T> a, out_<T> b)
{
std::cout << a;
std::cin >> b;
}
int i = 0, j;
f(in i, out j);
It would be better if you rename the "out" parameter to "in_out" or "reference". C++ has only one "out", it is a function result. C# and COM have "out" parameters.
The only reason is for call semantics:
E.g.:
void f(out_<int> i);
void g(inout_<int> i);
int i;
f(out(i));
// f(inout(i)); // ERROR !
g(inout(i));
// g(out(i)); // ERROR !