Created
February 14, 2017 01:03
-
-
Save utilForever/a7684f9a7f0b63aa66408f01c29354c8 to your computer and use it in GitHub Desktop.
std::is_constructible, std::is_trivially_constructible, std::is_nothrow_constructible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <type_traits> | |
class Foo { | |
int v1; | |
double v2; | |
public: | |
Foo(int n) : v1(n), v2() {} | |
Foo(int n, double f) noexcept : v1(n), v2(f) {} | |
}; | |
int main() { | |
std::cout << "Foo is ...\n" << std::boolalpha | |
<< "\tTrivially-constructible from const Foo&? " | |
<< std::is_trivially_constructible<Foo, const Foo&>::value << '\n' | |
<< "\tTrivially-constructible from int? " | |
<< std::is_trivially_constructible<Foo, int>::value << '\n' | |
<< "\tConstructible from int? " | |
<< std::is_constructible<Foo, int>::value << '\n' | |
<< "\tNothrow-constructible from int? " | |
<< std::is_nothrow_constructible<Foo, int>::value << '\n' | |
<< "\tNothrow-constructible from int and double? " | |
<< std::is_nothrow_constructible<Foo, int, double>::value << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment