Bruce Trask writes:
I need to create a sequence of float values that the user can put in at compile time. Since floats cannot be used as template params I am assuming I cannot use vector_c in any way.
Correct.
My plan was to have the user input the initial float values as mpl::vector<char> and then convert the chars to string and then the string to float when I needed to use it at runtime.
From a user standpoint, this one sounds somewhat painful.
My other idea was to make a struct that inherited from mpl::pair and have the first part be the integral part and the second part be the decimal part and again, construct the float from that.
Been there, please see http://article.gmane.org/gmane.comp.lib.boost.devel/103064.
So the two ideas look something like:
[snip code]
What do you think of these ideas?
I am assuming that there must be other solutions and perhaps these are not the best.
I think "the best" here heavily depends on the particular details of your application for the whole thing. For instance, if you need compile-time arithmetics on these, the "decimal" representation would probably be the easiest one to build a prototype for. On the other hand, if expect your users to enter a lot of these numbers, you might want to reconsider at least the interface part -- et cetera. Be sure to check Cromwell Enage's work on the subject: http://thread.gmane.org/gmane.comp.lib.boost.devel/103302. HTH, -- Aleksey Gurtovoy MetaCommunications Engineering