News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.

Started by killerbot, September 19, 2010, 09:23:36 AM

Previous topic - Next topic

ollydbg

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Loaden

Quote from: oBFusCATed on September 24, 2010, 10:31:04 AM
As far as I know nullptr is defined somewhere in CB's sources, so it could be used.

p.s. nullptr will be in gcc 4.6 :)
Rewritten nullptr.
docs: http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/nullptr

Loaden

Rewritten nullptr again.

#if (  __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) ) \
    && !defined __GXX_EXPERIMENTAL_CXX0X__
const class nullptr_t
{
public:
    template<typename T> operator T* () const { return (T*)0; }
    template<typename C, typename T> operator T C::* () const { return (T C::*)0; }
    template<typename T> bool equals(T const& rhs) const { return rhs == 0; }
private:
    void operator&() const;
} 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()
{
    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;
}
:lol:

[attachment deleted by admin]

oBFusCATed

Loaden you can't implement nullptr using c++98 or c++03, if should be added to the language!
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Loaden

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!
I know, However, Before added to the language, we can first use it to replace, in order to C++0x.
:)

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!
I know, However, Before added to the language, we can first use it to replace, in order to C++0x.
:)
Quote#if (  __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) ) \
    && !defined __GXX_EXPERIMENTAL_CXX0X__

const class nullptr_t
{
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:
#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;
}

blueshake

Quote from: blueshake on September 22, 2010, 04:59:56 PM
support member variable initialation codecompletion now

nice to visit the forum again.
here is the patch.
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

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
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Loaden

Quote from: thomas on September 27, 2010, 05:09:24 PM
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
This seems more like we do not know there is a nullptr implement in CB's sdk.
Use nullptr instead of 0 (or NULL) is sooner or later.
I like the C++0x.  :)

Loaden

Quote from: blueshake on September 27, 2010, 02:21:47 PM
Quote from: blueshake on September 22, 2010, 04:59:56 PM
support member variable initialation codecompletion now

nice to visit the forum again.
here is the patch.
Nice! The patch improved code completion in member variable init position.
Now it will works better.

huliming2004

a.h

namespace A{
    class myclass{
        public:
            void myfunc();
    }
}

a.cpp

using namespace A;

void myclass::myfunc(){
   //codes here
}

where i right clicked "void myfunc()"  in file "a.h" and choose "find implemetion of myfunc()", but failed with "not found myfunc()"
i know it's because of namespace, if i add namespace like this: A::myclass::myfunc(), it's fine

Loaden

Quote from: huliming2004 on October 01, 2010, 11:59:14 PM
a.h

namespace A{
   class myclass{
       public:
           void myfunc();
   }
}

a.cpp

using namespace A;

void myclass::myfunc(){
  //codes here
}

where i right clicked "void myfunc()"  in file "a.h" and choose "find implemetion of myfunc()", but failed with "not found myfunc()"
i know it's because of namespace, if i add namespace like this: A::myclass::myfunc(), it's fine

confirmed!
And this code could be parse well.

a.cpp

namespace A
{
void myclass::myfunc(){
  //codes here
}
}

ollydbg

Quote from: Loaden on October 02, 2010, 03:11:58 AM
a.cpp
namespace A
{
   void myclass::myfunc(){
  //codes here
   }
}

Yes, I prefer using this way, and CC works fine.
and Currently CC does not handling "using namespace XXX " directive correctly.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.