|
Boost Users : |
Subject: Re: [Boost-users] [Fusion] Adapting read-only fields of ADTs
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2011-04-12 13:18:20
Joel de Guzman <joel_at_[hidden]> writes:
[...]
> That's a good workaround, but really, we ought to have read-only
> adaptors. Doing above would still allow elem = val; albeit will
> be a no-op.
>
> Please add a trac "feature request" ticket, if you will.
>
> Regards,
A simple workaround is to fall back to an invalid expression.
--8<---------------cut here---------------start------------->8---
#include<boost/fusion/adapted.hpp>
#include<boost/fusion/sequence.hpp>
template<typename>struct dummy{};
template<typename T>
typename dummy<T>::this_type_does_not_exist
invalid_operation(T const&)
{}
class A{};
BOOST_FUSION_ADAPT_ADT(A,(int,int,1,invalid_operation(val)))
int main()
{
A a;
boost::fusion::front(a)=1;
}
--8<---------------cut here---------------end--------------->8---
This should give a nice and readable error message.
-Christopher
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net