[mpl] Using max_element inside a fold while constructing a vector
Hi,
I have been using boost.mpl for the first time recently and have solved a
number of tasks with boost.mpl now but have a problem with a bit of code I
thought should be working.
What is wrong with this bit of code using boost.mpl?
typedef vector
AMDG On 05/29/2013 08:55 PM, Brendon Costa wrote:
I have been using boost.mpl for the first time recently and have solved a number of tasks with boost.mpl now but have a problem with a bit of code I thought should be working.
What is wrong with this bit of code using boost.mpl?
typedef vector
, int_<3>, int_<2> > v1; // I want to use max_element on a vector I am in the process of constructing using a fold typedef typename fold
>, push_back<_1, deref ::type >::type> >::type v2;
try push_back<_1, deref
try push_back<_1, deref
> >. i.e. don't use ::type in an MPL Lambda expression.
That doesn't work either. Below is a full code example as I think it should
be from your feedback (I have tried in GCC and MSVC2010):
#include
::type v2;
struct print_value
{
template <typename data_tpt>
void operator()(data_tpt p)
{
//Uncommenting this is what I would like but fails to compile
//std::cerr << "value: " << data_tpt::value << std::endl;
std::cerr << "value: " << typeid(p).name() << std::endl;
}
};
int main()
{
for_each
AMDG On 05/31/2013 06:35 PM, Brendon Costa wrote:
try push_back<_1, deref
> >. i.e. don't use ::type in an MPL Lambda expression. That doesn't work either. Below is a full code example as I think it should be from your feedback (I have tried in GCC and MSVC2010):
What version of Boost are you using? The code doesn't compile with the current trunk because of a bug that prevents max_element from working in lambdas. After I fix that it works fine. In Christ, Steven Watanabe
I am using: * gcc 4.5.3 and boost 1.50 : Compiles but produces unexpected result * MSVC 2010 and boost 1.53 : Doesn't compile On Sunday, 2 June 2013, Steven Watanabe wrote:
AMDG
On 05/31/2013 06:35 PM, Brendon Costa wrote:
try push_back<_1, deref
> >. i.e. don't use ::type in an MPL Lambda expression. That doesn't work either. Below is a full code example as I think it should be from your feedback (I have tried in GCC and MSVC2010):
What version of Boost are you using? The code doesn't compile with the current trunk because of a bug that prevents max_element from working in lambdas. After I fix that it works fine.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Brendon Costa
-
Steven Watanabe