Author Topic: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.  (Read 84721 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #75 on: September 24, 2010, 11:06:18 am »
ibpp(http://www.ibpp.org/)  and CC problem still not solved
http://forums.codeblocks.org/index.php/topic,11844.msg80492.html#msg80492
Operator overload for "->" is added at least for some std containers.
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.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #76 on: September 24, 2010, 02:56:16 pm »
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
« Last Edit: September 24, 2010, 04:11:29 pm by Loaden »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #77 on: September 24, 2010, 04:16:55 pm »
Rewritten nullptr again.
Code
#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]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #78 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!
(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!]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #79 on: September 24, 2010, 04:35:05 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.
 :)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #80 on: September 24, 2010, 04:40:19 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.

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #81 on: September 25, 2010, 03:12:42 am »
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;
}

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #82 on: September 27, 2010, 02:21:47 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?

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #83 on: September 27, 2010, 02:24:13 pm »
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 ....

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #84 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
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #85 on: September 28, 2010, 08:21:59 am »
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.  :)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #86 on: September 28, 2010, 08:31:00 am »
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.

Offline huliming2004

  • Single posting newcomer
  • *
  • Posts: 6
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #87 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
« Last Edit: October 02, 2010, 12:02:42 am by huliming2004 »

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #88 on: October 02, 2010, 03:11:58 am »
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
}
}

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: The 19 september 2010 build (6608) CODECOMPLETION BRANCH version is out.
« Reply #89 on: October 02, 2010, 09:45:16 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.