c++ - boost::call_traits - Why is gcc giving false for this? -


example:

#include <iostream> #include <boost/call_traits.hpp> #include <type_traits>  boost::call_traits<int>::param_type f() {         return 1; }  int main() {         std::cout << std::boolalpha;         std::cout <<         std::is_const<boost::call_traits<int>::param_type>::value         << std::endl; // true         std::cout << std::is_const<decltype(f())>::value << std::endl; // false  } 

question:

unless, doing wrong, think should getting true both, gcc 4.7.0 outputs false latter. there missing?

a non-class type rvalue never const-qualified. class-type rvalues may const-qualified.

so, though function f declared returning const int, , though type of function f const int(), call expression f() rvalue of type (non-const) int.

(in the new c++11 expression category taxonomy, call expression f() prvalue of type int. same rule applies: c++11 §3.10/4 states "non-class prvalues have cv-unqualified types.")


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -