Is atomic's _internal_reference broken?
I keep getting compile errors (in VC8) when trying to use atomic's _internal_reference member (which is public).
When doing this:
atomic<int> atomic_int;
atomic_int = 5;
const int& your_int = atomic_int._internal_reference();
I get this error message:
1>d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(230) : error C2440: 'static_cast' : cannot convert from 'const int' to 'int &'
1> static_cast and safe_cast to reference can only be used for valid initializations or for lvalue casts between related classes
1> d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(229) : while compiling class template member function 'int &tbb::internal::atomic_impl<I,D,Step>::_internal_reference(void) const'
1> with
1> [
1> I=int,
1> D=int,
1> Step=1
1> ]
1> d:projectsspikeslibrariestbb21_012ossincludetbb/atomic.h(321) : see reference to class template instantiation 'tbb::internal::atomic_impl<I,D,Step>' being compiled
1> with
1> [
1> I=int,
1> D=int,
1> Step=1
1> ]
Now I did the following const_cast to solve the issue:
File:tbb/atomic.h
Line: 230
value_type& _internal_reference() const {
return static_cast<value_type&>(const_cast<atomic_impl<I,D,Step>* >(this)->my_value);
}
However... I'm not sure if that's the problem at all,
because first of all _internal_reference doesn't look like something
that should be in the public interface at all.
What's the story about this?
|