User forums > Nightly builds
The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
Loaden:
--- Quote from: Loaden on September 24, 2010, 04:35:05 pm ---
--- Quote from: oBFusCATed on September 24, 2010, 04:23:43 pm ---Loaden you can't implement nullptr using c++98 or c++03, if should be added to the language!
--- End quote ---
I know, However, Before added to the language, we can first use it to replace, in order to C++0x.
:)
--- End quote ---
--- Quote ---#if ( __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) ) \
&& !defined __GXX_EXPERIMENTAL_CXX0X__
const class nullptr_t
{
--- End quote ---
I put nullptr_t in guard, that meaning: we can use nullptr if the nullptr is not added to the language. (GCC >= 4.6 && -std=c++0x)
If the nullptr has added to the language, we can not use this nullptr class any more.
Loaden:
V3
test demo:
--- Code: ---#if ( __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) ) \
&& !defined __GXX_EXPERIMENTAL_CXX0X__
// it is a const object...
const class nullptr_t
{
public:
// constructor
nullptr_t() {}
// convertible to any type of null non-member pointer...
template<typename T> operator T* () const{ return (T*)0; }
// or any type of null member pointer...
template<typename C, typename T> operator T C::* () const { return (T C::*)0; }
// support operator overloading (== and !=)
template<typename T> bool equals(T const& rhs) const { return rhs == 0; }
private:
// can't take address of nullptr
void operator&() const;
// can't copyable
nullptr_t(const nullptr_t&);
const nullptr_t& operator=(const nullptr_t&);
} nullptr;
template<typename T> inline bool operator==(const nullptr_t& lhs, T const& rhs) { return lhs.equals(rhs); }
template<typename T> inline bool operator==(T const& lhs, const nullptr_t& rhs) { return rhs.equals(lhs); }
template<typename T> inline bool operator!=(const nullptr_t& lhs, T const& rhs) { return !lhs.equals(rhs); }
template<typename T> inline bool operator!=(T const& lhs, const nullptr_t& rhs) { return !rhs.equals(lhs); }
#endif
class A {};
int main()
{
nullptr_t* n2;
n2 = nullptr;
int* p = nullptr;
if (p == nullptr || p != nullptr)
;
if (nullptr == p || nullptr != p)
;
A* a = nullptr;
if (a == nullptr || a != nullptr)
;
if (nullptr == a || nullptr != a)
;
return 0;
}
--- End code ---
blueshake:
--- Quote from: blueshake on September 22, 2010, 04:59:56 pm ---support member variable initialation codecompletion now
--- End quote ---
nice to visit the forum again.
here is the patch.
killerbot:
new nightlies (well the one from Saturday, coming this evening), you can find them already at berlios, but now that the forum is back they can be posted ....
thomas:
Not sure if we really need this. We've had a nullptr implementation since 2007 (I wrote that one before being aware of Meyer's more elegant solution), and nobody ever cared to use nullptr anywhere in the code :P
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version