Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualÁlvaro

Posted 30 April 2013 - 07:33 AM

UDTs can be compile-time constants, sure. But they won't ever be zero-storage because that doesn't quite make sense :-)

 
 

Things like structures and arrays take up memory for obvious reasons (though they'll be in the read-only area).

 
I don't know what you guy means by "doesn't quite make sense" and "for obvious reasons". The following three programs generate the same executable byte for byte (using g++ 4.7.1):
#include <iostream>

int main() {
  std::cout << 5 << '\n';
}
#include <iostream>

int main() {
  int const i = 5;
  std::cout << i << '\n';
}
#include <iostream>

struct X {
  int x;
 
  X(int x) : x(x) {
  }
};

int main() {
  X const i = 5;
  std::cout << i.x << '\n';                                                                                   
}                                                                                                           

#3Álvaro

Posted 30 April 2013 - 07:32 AM

UDTs can be compile-time constants, sure. But they won't ever be zero-storage because that doesn't quite make sense :-)

 
 

Things like structures and arrays take up memory for obvious reasons (though they'll be in the read-only area).

 
I don't know what you guys means by "doesn't quite make sense" and "for obvious reasons". The following three programs generate the same executable byte for byte (using g++ 4.7.1):
#include <iostream>

int main() {
  std::cout << 5 << '\n';
}
#include <iostream>

int main() {
  int const i = 5;
  std::cout << i << '\n';
}
#include <iostream>

struct X {
  int x;
 
  X(int x) : x(x) {
  }
};

int main() {
  X const i = 5;
  std::cout << i.x << '\n';                                                                                   
}                                                                                                           

#2Álvaro

Posted 30 April 2013 - 07:30 AM

UDTs can be compile-time constants, sure. But they won't ever be zero-storage because that doesn't quite make sense :-)

 

 

Things like structures and arrays take up memory for obvious reasons (though they'll be in the read-only area).

 

I don't know what you guys means by "doesn't quite make sense" and "for obvious reasons". The following two programs generate the same executable byte for byte (using g++ 4.7.1):

 

 

#include <iostream>

int main() {
  int const i = 5;
  std::cout << i << '\n';
}

 

 

#include <iostream>

struct X {
  int x;
 
  X(int x) : x(x) {
  }
};

int main() {
  X const i = 5;
  std::cout << i.x << '\n';                                                                                   
}                                                                                                           

#1Álvaro

Posted 30 April 2013 - 07:30 AM

UDTs can be compile-time constants, sure. But they won't ever be zero-storage because that doesn't quite make sense :-)

 

Things like structures and arrays take up memory for obvious reasons (though they'll be in the read-only area).

 

I don't know what you guys means by "doesn't quite make sense" and "for obvious reasons". The following two programs generate the same executable byte for byte:

 

#include <iostream>

int main() {
  int const i = 5;
  std::cout << i << '\n';
}

 

#include <iostream>

struct X {
  int x;
 
  X(int x) : x(x) {
  }
};

int main() {
  X const i = 5;
  std::cout << i.x << '\n';                                                                                   
}                                                                                                           

PARTNERS