fix gcc build

This commit is contained in:
Neargye 2018-07-14 00:02:03 +05:00
parent 63584dbf30
commit 1e3f53ba5f
2 changed files with 16 additions and 12 deletions

View file

@ -26,6 +26,7 @@
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <typeinfo>
constexpr long double operator"" _deg(long double deg) { constexpr long double operator"" _deg(long double deg) {
return deg * 3.141592 / 180.0; return deg * 3.141592 / 180.0;
@ -36,7 +37,7 @@ std::string operator"" _string(const char* str, std::size_t) {
} }
struct SomeStruct { struct SomeStruct {
int somefield; int somefield = 0;
void SomeMethod1(const int i) { void SomeMethod1(const int i) {
somefield = i; somefield = i;
@ -52,11 +53,13 @@ void SomeMethod3() {
} }
template <typename T> template <typename T>
void SomeMethod4() {} T SomeMethod4() {
return T{};
}
struct Long { struct Long {
struct LL { struct LL {
int field; int field = 0;
}; };
LL ll; LL ll;
}; };
@ -65,9 +68,9 @@ enum class Color { RED, GREEN, BLUE };
SomeStruct somevar; SomeStruct somevar;
Long othervar; Long othervar;
int intvar; int intvar = 0;
SomeStruct* ptrvar; SomeStruct* ptrvar = &somevar;
SomeStruct** ptrptrvar; SomeStruct** ptrptrvar = &ptrvar;
int main() { int main() {
// constexpr // constexpr
@ -145,7 +148,8 @@ int main() {
std::cout << NAMEOF(std::string()) << std::endl; // 'string()' std::cout << NAMEOF(std::string()) << std::endl; // 'string()'
std::cout << NAMEOF(std::string{}) << std::endl; // "string{}' std::cout << NAMEOF(std::string{}) << std::endl; // "string{}'
std::cout << NAMEOF(std::string{"test"}) << std::endl; // 'string{"test"}' std::cout << NAMEOF(std::string{"test"}) << std::endl; // 'string{"test"}'
std::cout << NAMEOF(SomeMethod4<int>) << std::endl; // '' std::cout << NAMEOF(SomeMethod4<int>()) << std::endl; // '()'
std::cout << NAMEOF(std::basic_string<char>) << std::endl; // ''
std::cout << NAMEOF(ptrvar[0]) << std::endl; // 'ptrvar[0]' std::cout << NAMEOF(ptrvar[0]) << std::endl; // 'ptrvar[0]'
std::cout << NAMEOF(intvar + intvar) << std::endl; // ' intvar' std::cout << NAMEOF(intvar + intvar) << std::endl; // ' intvar'
std::cout << NAMEOF(NAMEOF(intvar)) << std::endl; // 'NAMEOF(intvar)' std::cout << NAMEOF(NAMEOF(intvar)) << std::endl; // 'NAMEOF(intvar)'

View file

@ -31,7 +31,7 @@
#include <stdexcept> #include <stdexcept>
struct SomeStruct { struct SomeStruct {
int somefield; int somefield = 0;
void SomeMethod1(const int i) { void SomeMethod1(const int i) {
somefield = i; somefield = i;
@ -48,7 +48,7 @@ void SomeMethod3() { throw std::exception{}; }
struct Long { struct Long {
struct LL { struct LL {
int field; int field = 0;
}; };
LL ll; LL ll;
}; };
@ -57,9 +57,9 @@ enum class Color { RED, GREEN, BLUE };
SomeStruct somevar; SomeStruct somevar;
Long othervar; Long othervar;
int intvar; int intvar = 0;
SomeStruct* ptrvar; SomeStruct* ptrvar = &somevar;
SomeStruct** ptrptrvar; SomeStruct** ptrptrvar = &ptrvar;
TEST_CASE("constexpr") { TEST_CASE("constexpr") {
SECTION("NAMEOF") { SECTION("NAMEOF") {