>> I'm not even sure I understand the contract. How can you
>> round to a number of decimal places when the result is not
>> necessarily representable?
Good question. Not sure I have an answer. I just
evolved these algorithms becouse I couldnt find them anywhere
else.
>> Rather than an implementation, could you
>> provide an example of a documentation, stating precisely what the
>> return value should be?
Sure. I could do that.
>> Also, if the …
[View More]intention is float/double/long
>> double, why templates, as opposed to three overloads? Thanks for any
>> clarification.
Well, this is boost after all. What tradeoffs do you see?
>> Equally useful as rounding, perhaps, would be printing to a string
>> with guaranteed rounding. You know that printing or reading a binary
>> floating point to a decimal string representation, and back, may not
>> result in the same number. This goes with printf and scanf, as well
>> as I/O streams (perhaps this has been corrected but I haven't seen
>> anything very sophisticated in the STL implementations I lurk in).
>> There are known algorithms to do this with guaranteed rounding, e.g.:
I'm not an expert here. If you would be willing to advise me on
these issues, I might be persuaded to put together some
test cases and example files. I know there alot of subtle
issues involved with rounding floating point numbers.
[View Less]
Greetings,
boost::optional<T &> seems to be implemented in terms of a boolean flag and an
aligned_storage. Wouldn’t it make more sense to make boost::optional<T &> a
thin wrapper over T*? This would save a couple of bytes, speed up get_ptr by
a couple of ticks, and perhaps reduce compilation times.
Also, from the documentation[1]:
> Rebinding semantics for the assignment of initialized optional references
has been chosen to provide consistency among initialization …
[View More]states even at
the expense of lack of consistency with the semantics of bare C++ references.
It is true that optional<U> strives to behave as much as possible as U does
whenever it is initialized; but in the case when U is T&, doing so would
result in inconsistent behavior w.r.t to the lvalue initialization state.
optional<U> does not have the semantics of U, but rather those of U*. That
explains the assignment semantics perfectly well:
int a = 1;
int b = 2;
int& ra = a;
int& rb = b;
int* pa = &a;
int* pb = &b;
boost::optional<int &> oa(ra);
boost::optional<int &> ob(rb);
ra = rb; // assigns b to a
pa = pb; // rebinds pa to b
oa = ob; // rebinds oa to b
--
[1] http://tinyurl.com/55s8f7
--
WBR
Roman.
[View Less]
Hi,
My attempt to inherit boost graph failed. The compiler complains that it
is not aware of boost graph classes.
Would appreciate if someone can tell if this due to boost intricacies or
just regular mistake in the syntax.
//Declare boost graph within namespace boostd
namespace boostd {
typedef adjacency_list<listS, listS, ... > Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
}
class DerivedGraph: public boostd::Graph{
public:
class Node: public …
[View More]boostd::Vertex{ //error on
this line
};
};
The compiler complains
error: expected class-name before '{' token
Thanks
sandeep
[View Less]