I tried to solve a C++ symbol problem but I could not find a solution:
here is my code:
#include <iostream>
#include <type_traits>
using namespace std;
/*
* static_assert(constant-expression, error-message): static_assert provides compile-time asserts.
* type traits: characteristics checked at compile-time
*/
template<class T>
T bitwise_and(T x, T y) {
static_assert(is_integral<T>::value, "bitwise_and parameters must be of integral type");
return x % y;
}
int main() {
//1. Basic static_assert example
static_assert(sizeof(long) == 8 , "32 bit required");
//2. calling a generic function that enforces type rules with static_assert
unsigned int x = 122127, y = 10;
int r = bitwise_and(x, y);
cout << r << endl;
unsigned char c = 10, d = 2;
int r1 = bitwise_and(c, d);
cout << r1 << endl;
// assert is not valid
//double w = 1, z = 10;
//int r2 = bitwise_and(w, z);
cout << "End" << endl; // prints
return 0;
}
I have added the option -std=c++11 to eclipse Mars.2 (4.5.2) like this:
but its not working
I have tried -std=c++14, its not working too any idea ?
my c++11 setting is working for other new language features
Note: the code in running fine under visual studio 2015 community edition
here is the errors after build:
gcc: gcc version 5.3.1 20160406 (Red Hat 5.3.1-6) (GCC)
thanks.