Author Topic: Hey, guys, I have a good idea!  (Read 8144 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Hey, guys, I have a good idea!
« on: January 26, 2010, 01:20:32 am »
For example this code, 'p' is a pointer, and 'a' is a value.
If type "p." or "a.", they show the same results.

Code
#include <iostream>

class A
{
public:
    A();
    ~A();

    void testMsg() {}

private:
    int iLoveYou;
};

int main()
{
    A* p = new A;
    A a;
    a.testMsg();
    return 0;
}

Because CC can identified a pointer, or value, so we can do that:
If it is a pointer, then automatically replace from "." to  "->", like this:
form:
Code
p.testMsg();
to:
Code
p->testMsg();

[attachment deleted by admin]

Offline TerryP

  • Multiple posting newcomer
  • *
  • Posts: 26
    • My journal
Re: Hey, guys, I have a good idea!
« Reply #1 on: January 26, 2010, 01:37:24 am »
Useful, might I also suggest handling an accidental ',' as well?

*groans* I still remember spending trying to figure out a compiler error, over an x,y typo, after an 8~12 hour straight coding run.
Just Another Computer Geek

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5737
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Hey, guys, I have a good idea!
« Reply #2 on: January 26, 2010, 02:57:42 am »
blueshake has suggested that feature before, but there are objections.
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: Hey, guys, I have a good idea!
« Reply #3 on: January 26, 2010, 03:35:01 am »
blueshake has suggested that feature before, but there are objections.

But such tips is clearly a very ridiculous!
p.testMsg();
Code
int main()
{
    A* p = new A;
    p.testMsg();
    return 0;
}

Both of “Qt Creator” and “Visual Assist X” selected from the "." To "->" conversion.
I hope CC team to re-consider this feature.
Thanks!
« Last Edit: January 26, 2010, 03:39:47 am by Loaden »

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Hey, guys, I have a good idea!
« Reply #4 on: January 26, 2010, 06:54:00 am »
but how about the "smart pointer"?

std::auto_ptr<MyStruct>  ap (new MyStruct());

ap. ?? //now the cc show thoese tips:
     release()
     get()

ap->  //show nothing.


Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: Hey, guys, I have a good idea!
« Reply #5 on: January 27, 2010, 02:14:30 pm »
Quote
“Qt Creator”

@Loaden

since Qt Creator can do this , I think cc can do this in the future too. :D
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13438
    • Travis build status
Re: Hey, guys, I have a good idea!
« Reply #6 on: January 27, 2010, 03:38:25 pm »
but how about the "smart pointer"?

std::auto_ptr<MyStruct>  ap (new MyStruct());

ap. ?? //now the cc show thoese tips:
     release()
     get()

ap->  //show nothing.


CC Doesn't support operator overloading
(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!]