Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 368404 - Error involving template partial specializations for pointers
Summary: Error involving template partial specializations for pointers
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.1.0   Edit
Assignee: Markus Schorn CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-11 22:36 EST by Nathan Ridge CLA
Modified: 2012-02-29 13:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Ridge CLA 2012-01-11 22:36:44 EST
test.hpp:

template <typename T> 
struct remove_const_impl {};

template <typename T>
struct remove_const_impl<T*>
{
    typedef T type;
};

template <typename T>
struct remove_const_impl<const T*>
{
    typedef T type;
};

template <typename T>
struct remove_const
{
    typedef typename remove_const_impl<T*>::type type;
};


test.cpp:

#include "test.hpp"

template<typename Seq>
struct foo;

template <>
struct foo<int>
{
    typedef int type;
};

typedef foo<remove_const<const int>::type>::type t;  // ERROR HERE


The error at the indicated line is: "Type 'foo<remove_const<const int>::type>::type' could not be resolved"

The error goes away in the following cases:
  - contents of test.hpp are pasted into test.cpp
  - test.cpp calls remove_const<int> instead of remove_const<const int>
  - test.cpp calls remove_const_impl directly instead of through the remove_const wrapper
  - remove_const_impl is modified to specialize on T and const T, rather than T* and const T*
Comment 1 Markus Schorn CLA 2012-01-13 09:06:09 EST
Added testcase and fix.
Comment 2 CDT Genie CLA 2012-02-29 13:21:16 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368404: Current instantiation of class template partial specializations.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=1467a456bd822e30ce023b723bf21aecb98798db
Comment 3 CDT Genie CLA 2012-02-29 13:21:18 EST
*** cdt git genie on behalf of Markus Schorn ***

    Bug 368404: Testcase.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=59c4d10629cf7e8567ffb9759022212654c58615