yeah, of course using the _expression_ (or a value) directly works. I think that the constexpr method isn't properly analyzed by the parser. The bug report isn't yet closed, should I add this test case?
On Friday 05 Jul 2013 10:27:23 Corbat Thomas wrote:
> Hi
>
> I think the problem origins from the fact that getID() is a constexpr function. If I replace "A::getID()" in the template argument of B with the corresponding part of its return statement "static_cast<uint16_t>(TEST_ID)" the problem vanishes. Therefore, it would be related to this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=332829
> I'm not sure whether your case should already be working or not.
>
> Regards
> Thomas
>
>
>
> From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of scalpel4k
> Sent: Freitag, 5. Juli 2013 12:00
> To: CDT General developers list.
> Subject: [cdt-dev] resolution error
>
>
> Hi guys,
>
>
>
> I am facing a little problem using templates. The following code example produces a symbol resolution error message while the compiler itself does not choke at all.
>
> I tend to say that I don't need the explicit static_cast in class C, so is this a bug which I should report?
>
>
>
> #include <stdint.h>
>
>
>
> #define TEST_ID 0
>
>
>
> struct A {
>
>
>
> static constexpr uint16_t getID() {
>
> return static_cast<uint16_t>(TEST_ID);
>
> }
>
>
>
> };
>
>
>
> template<uint16_t ID>
>
> struct B {
>
>
>
> static constexpr uint16_t getID() {
>
> return ID;
>
> }
>
>
>
> };
>
>
>
> struct C {
>
>
>
> static uint16_t getID_0 () {
>
> return B<static_cast<uint16_t>(A::getID())>::getID(); // why do I
>
> }
>
>
>
> static uint16_t getID_1 () {
>
> return B<A::getID()>::getID(); // resolution error
>
> }
>
>
>
> }; |