Commit Graph

14 Commits

Author SHA1 Message Date
Douglas Gregor 181aa4a250 Improve template argument deduction to keep track of why template
argument deduction failed. For example, given

  template<typename T> struct is_same<T, T> { ... };

template argument deduction will fail for is_same<int, float>, and now
reports enough information

Right now, we don't do anything with this extra information, but it
can be used for informative diagnostics that say, e.g., "template
argument deduction failed because T was deduced to 'int' in one
context and 'float' in another".

llvm-svn: 73237
2009-06-12 18:26:56 +00:00
Anders Carlsson a767eeed19 Deducation and instantiation of block types.
llvm-svn: 73232
2009-06-12 16:23:10 +00:00
Douglas Gregor 74eba0b679 Once we have deduced the template arguments of a class template
partial specialization, substitute those template arguments back into
the template arguments of the class template partial specialization to
see if the results still match the original template arguments.

This code is more general than it needs to be, since we don't yet
diagnose C++ [temp.class.spec]p9. However, it's likely to be needed
for function templates.

llvm-svn: 73196
2009-06-11 18:10:32 +00:00
Douglas Gregor 637d9984f0 Template argument deduction for member pointers.
Also, introduced some of the framework for performing instantiation as
part of template argument deduction.

llvm-svn: 73175
2009-06-10 23:47:09 +00:00
Douglas Gregor 4fbe3e3014 Implement template argument deduction for class template
specialization types. As the example shows, we can now compute the
length of a type-list using a template metaprogram and class template
partial specialization.

llvm-svn: 73136
2009-06-09 16:35:58 +00:00
Anders Carlsson 096e6eeb68 Address comments from Doug.
llvm-svn: 73077
2009-06-08 19:22:23 +00:00
Douglas Gregor f661016b03 Document the template argument deduction patterns that Anders' patch supports
llvm-svn: 73071
2009-06-08 15:59:14 +00:00
Anders Carlsson 2128ec7cdd Template argument deduction for function types.
llvm-svn: 73070
2009-06-08 15:19:08 +00:00
Anders Carlsson 184cb4123e Make TemplateArgumentListBuilder take an ASTContext (because we're probably going to need it later). Move push_back to the .cpp file. If the passed in template argument is a type, assert that it's canonical.
llvm-svn: 72918
2009-06-05 05:31:27 +00:00
Anders Carlsson c8e7113a9f Make the TemplateArgumentList take a TemplateArgumentListBuilder.
llvm-svn: 72917
2009-06-05 04:47:51 +00:00
Douglas Gregor b7ae10f764 Several improvements to template argument deduction:
- Once we have deduced template arguments for a class template partial
    specialization, we use exactly those template arguments for instantiating
    the definition of the class template partial specialization.
  - Added template argument deduction for non-type template parameters.
  - Added template argument deduction for dependently-sized array types.

With these changes, we can now implement, e.g., the remove_reference
type trait. Also, Daniel's Ackermann template metaprogram now compiles
properly.

llvm-svn: 72909
2009-06-05 00:53:49 +00:00
Anders Carlsson 35533d11b3 Template argument deduction for incomplete and constant array types. Doug, please review.
llvm-svn: 72844
2009-06-04 04:11:30 +00:00
Douglas Gregor 5cdac0a52e Template argument deduction for references
llvm-svn: 72822
2009-06-04 00:21:18 +00:00
Douglas Gregor 55ca8f6443 When performing template argument deduction, ensure that multiple
deductions of the same template parameter are equivalent. This allows
us to implement the is_same type trait (!).

Also, move template argument deduction into its own file and update a
few build systems with this change (grrrr).

llvm-svn: 72819
2009-06-04 00:03:07 +00:00