Skip to content

Instantly share code, notes, and snippets.

@theodoregoetz
Created September 10, 2015 22:58
Show Gist options
  • Save theodoregoetz/bae909c3b98c247dc530 to your computer and use it in GitHub Desktop.
Save theodoregoetz/bae909c3b98c247dc530 to your computer and use it in GitHub Desktop.
C++ Constructor with rvalue
#include <iostream>
struct Foo
{
public:
Foo(int d) : x(d) {}
int x;
};
int main()
{
double x = 3.14;
Foo f( int(x) ); // does not compile!
//Foo f( (int) x ); // OK
std::cout << f.x << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment