[cfe-dev] class template methods

Reid Kleckner rnk at google.com
Tue Apr 14 08:38:09 PDT 2015


Sounds a lot like a SFINAE test. Assuming you already have an AST with the
class template instantiation, then you'd attempt to instantiate the
assignment operator inside a SFINAETrap. Instantiation will either pass or
fail and you'll get your answer, and you should be able to continue
compilation or further queries normally.

On Mon, Apr 13, 2015 at 9:57 PM, Peter Stirling <peter at pjstirling.plus.com>
wrote:

> Hi,
>
> Is there a way to ask clang whether a method for an instantiation of a
> class template would be an error to call? (I only need yes/no)
>
> For example:
>
> std::pair has assignment operators defined, but for the instantiation
> std::pair<int const, int const> calling the assignment operators is an
> error, because you can't assign to int const.
>
> If clang can't tell me this, I'm looking at generating a translation unit
> with a call to the method, and then checking whether there was an error
> compiling it. Given that I will need to do this once per method, per
> instantiation, per template, (which looks to be in the thousands based on a
> test I just did) what is the best way to do this?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150414/e5700067/attachment.html>


More information about the cfe-dev mailing list