cmake/c++11-test-constexpr-N2235.cpp

Fri, 23 Aug 2013 01:20:09 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 23 Aug 2013 01:20:09 +0300
changeset 478
c7f8989c995f
parent 473
2a84149fe642
permissions
-rw-r--r--

bit of a clarification

473
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 constexpr int square(int x)
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 return x*x;
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 }
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 constexpr int the_answer()
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 return 42;
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 }
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 int main()
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 {
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 int test_arr[square(3)];
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 bool ret = (
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 (square(the_answer()) == 1764) &&
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 (sizeof(test_arr)/sizeof(test_arr[0]) == 9)
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 );
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18 return ret ? 0 : 1;
2a84149fe642 Changed build system from qmake to CMake.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 }

mercurial