Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - #include <climits>
 - using namespace std;
 - template <typename T> constexpr unsigned bits() {
 - return sizeof(T) * CHAR_BIT;
 - }
 - int main() {
 - constexpr int a = 1; // obviously fine
 - constexpr int b = bits<int>(); // fine
 - constexpr int c = 1 << 3; // fine
 - constexpr int d = 1 << bits<int>(); // error: constexpr variable 'd' must be initialized by a constant expression
 - constexpr int e = 1 + bits<int>(); // fine
 - return 0;
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment