This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++-0x] User defined literals.


On 07/12/2011 01:40 PM, Jason Merrill wrote:
Hmm, sorry I didn't notice this patch until now. Please CC me on C++ patches, and feel free to ping me if I don't respond promptly. Thanks for working on this!

2. Templates don't really work. This is proving difficult for my little brain.

I need to parse this:
123_abc;
and replace it with a call to

operator"" _abc<'1', '2', '3'>();

I can call
operator"" _abc<>();

In other words I can't figure out how to get the template args in.

There's stuff in there getting the template function out of OVERLOAD.
Then I try tsubst.  No dice.

Can you build up a TEMPLATE_ID_EXPR and then let the usual overload resolution code do the rest?


3. I can't get friend to work. The operator definition doesn't even get written.
I'm deferring this until after I get templates to work.

If you're talking about your udlit-friend.C test, I wouldn't expect that to work; friends are only found by argument-dependent lookup, and there is no argument of type Foo in the call


operator""_Bar('x')

+#define UDLIT_OP_MANGLED_PREFIX "__udlit"

Discussion on the ABI list seems to have settled on


li <source-name>
I put that in the new patch. Thanks.

as the mangling of a literal operator.


Rather than check lang == CXX0X or GNUCXX0X in libcpp, let's add a C++0x flag.
Where would you add the flag? cpp_token?

Perhaps in cpplib.h do this:
#define LITERAL_OP    (1 << 10) /* C++ user-defined literal.  */
?

There doesn't seem to be any need for USERDEF_LITERAL to be in the language-independent code; bits can go in c-common.h and c-common.def rather than tree.h and tree.def, etc.
On another tree I'm trying this. I'm having trouble getting everything moved down into c-family.

Thanks, Jason



Attachment: patch_literal4
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]