This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch for constexpr variable templates
- From: Ed Smith-Rowland <3dw4rd at verizon dot net>
- To: Braden Obrzut <admin at maniacsvault dot net>, Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Andrew Sutton <andrew dot n dot sutton at gmail dot com>
- Date: Fri, 25 Jul 2014 10:41:54 -0400
- Subject: Re: Patch for constexpr variable templates
- Authentication-results: sourceware.org; auth=none
- References: <53CCFBEF dot 9080804 at verizon dot net> <53CDD522 dot 9040508 at maniacsvault dot net> <53D172E4 dot 9020902 at redhat dot com> <53D242FD dot 70002 at maniacsvault dot net>
How difficult would it be to make partial specializations work:
// Write n*pi once for every possible type
template<typename Tp, std::size_t N>
constexpr Tp npi = N * Tp(3.1415926535897932385L);
// Partial specialization for int type.
template<std::size_t N>
constexpr double npi<int, N> = N * double(3.1415926535897932385L);