Opened 13 years ago
Closed 12 years ago
#3442 closed Feature Requests (wontfix)
tracking level etc. for templates
Reported by: | anonymous | Owned by: | Robert Ramey |
---|---|---|---|
Milestone: | Boost 1.41.0 | Component: | serialization |
Version: | Boost 1.40.0 | Severity: | Cosmetic |
Keywords: | Cc: |
Description
changing the tracking level/class implementation for tempaltes is very tedious to write and reveals implementation details to the user, so I'm suggesting the following macro:
template<class T,int i> class mytype{};
BOOST_CLASS_TRACKING_TEMPLATE(mytype,2,(class,int),track_never);
the implementation is fairly simple:
#define TYPE_TO_PAR(R,DATA,I,ELEM) (ELEM _A##I) #define PAR_SEQ(NR,PARS) BOOST_PP_SEQ_FOR_EACH_I(TYPE_TO_PAR,0,BOOST_PP_TUPLE_TO_SEQ(NR,PARS)) #define PARS(NR,PARS) BOOST_PP_SEQ_ENUM(PAR_SEQ(NR,PARS)) #define ARGS(NR) BOOST_PP_ENUM_PARAMS(NR,_A)
#define BOOST_CLASS_TRACKING_TEMPLATE(T,NR,P,TRACKING) \ template<PARS(NR,P)> struct tracking_level<T<ARGS(NR)> > {
typedef mpl::integral_c_tag tag; typedef mpl::int_<TRACKING> type; BOOST_STATIC_CONSTANT(
int, value = tracking_level::type::value
);
};
Change History (5)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Severity: | Problem → Cosmetic |
---|
Hmm - took me a while to figure this out. Very clever.
I'm not sure it's worth it though. This would mean
a) implementing this for ALL serialization traits not just one b) Adding explanation to the documentation c) Making tests to prove that it works on all compilers
So there's a fair bit of work involved. If you're still interested let me know
comment:3 by , 13 years ago
not immediatly, but I'll put it on my todo-list. I'm using this in a library I'm planning to submit for review, which requires the user to also use boost.serialization so it would be nice if that matched if the library will be accepted.
I'm only aware of tracking and imlpementation level, I have to look up what the other serialization traits are.
the thing I can't do is c) as I only have 2 compilers available.
comment:4 by , 13 years ago
which syntax do you prefer?
BOOST_CLASS_TRACKING_TEMPLATE(mytype,2,(class,int),track_never); or BOOST_CLASS_TRACKING_TEMPLATE(mytype,(class)(int),track_never);
(class,int) without an argument which gives the number of template parameters is not a possibility
comment:5 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Looking over all my items. I think I've come to terms with this.
It's a worthy idea. But I think it's too complicated to add to the library.
Also, it's not really an issue of serialization library, Rather it's an issue of exporting type traits in general. I think you should formulate this as an idea for boost and inquire on the list.
Robert Ramey
let me know if you agree with this but don't think it's worth your effort. I'll write a patch.