Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:52:32+00:00 2026-05-26T18:52:32+00:00

Can functions be used with user defined literals? If so, what shenanigans can be

  • 0

Can functions be used with user defined literals?

If so, what shenanigans can be done? Is this legal?

void operator "" _bar(int (*func)(int)) {
  func(1);
}

int foo(int x) {
  std::cout << x << std::endl;
}

int main() {
  foo(0);    // print 0
  foo_bar;   // print 1
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:52:33+00:00Added an answer on May 26, 2026 at 6:52 pm

    According to the C++11 Feb 2011 Draft § 2.14.8, the user literal types are integer-literals, floating-literals, string-literals, and character-literals. There is no way to do a function-literal type.

    A user-defined-literal is treated as a call to a literal operator or
    literal operator template (13.5.8). To determine the form of this call
    for a given user-defined-literal L with ud-suffix X, the
    literal-operator-id whose literal suffix identifier is X is looked up
    in the context of L using the rules for unqualified name lookup
    (3.4.1). Let S be the set of declarations found by this lookup. S
    shall not be empty.

    Integers:

    operator "" X (n ULL)
    operator "" X ("n")
    operator "" X <’c1’, ’c2’, ... ’ck’>()
    

    Floating:

    operator "" X (f L)
    operator "" X ("f")
    operator "" X <’c1’, ’c2’, ... ’ck’>()
    

    String:

    operator "" X (str, len)
    operator "" X <’c1’, ’c2’, ... ’ck’>() //unoffcial, a rumored GCC extension
    

    Character:

    operator "" X (ch)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the MSDN docs for create function : User-defined functions cannot be used to
I have a bunch of user-defined functions that are frequently used in mathematica. I
The dis module can be effectively used to disassemble Python methods, functions and classes
I have a mathparser that can do functions like IntPow(3,2). If a user pastes
I have a user defined function which is used in many stored procedures which
Where do i place the user defined functions in zend framework. These functions will
It is well known that the user can define stream manipulators like this: ostream&
I want to write a non-CLR user-defined function in SQL Server 2005. This function
The function CreateFileMapping can be used to allocate space in the pagefile (if the
In Python there is a really neat function called zip which can be used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.