Skip to main content
3 votes
1 answer
223 views

#include <chrono> #include <string> using namespace std::literals; int main() { ""s.size(); // ok (""s).size(); // ok (5ms).count(); // ok 5ms....
xmllmx's user avatar
  • 44.6k
1 vote
2 answers
82 views

I'm trying to parse UUID expression using C++23, However compiling under clang 20.1.6 and gcc 15.1.0 find the operator as candidates yet it get ignored. here is my code: union uuid_t { unsigned ...
Muhammad's user avatar
  • 1,707
1 vote
1 answer
117 views

#include <array> template<std::size_t tc_n> requires (tc_n > 0) struct StringLiteral final { std::array<char, tc_n> value{}; consteval StringLiteral(char const (&sl)[...
xmllmx's user avatar
  • 44.6k
5 votes
1 answer
62 views

I have two namespaces which both define the same User Defined Literals: namespace foo { struct x{ unsigned long long i; }; namespace literals { constexpr foo::x operator""_x(...
Dominik Kaszewski's user avatar
-2 votes
1 answer
72 views

namespace ns { class MyClass { private: int value; MyClass(int val) : value(val) {} friend MyClass operator"" _myudl(unsigned long long int val); // Friend UDL declaration ...
Ashcoll Ash's user avatar
0 votes
0 answers
168 views

I want to define a preprocessor macro with parameter N that constructs a declaration for C++ user-defined literal with suffix _uN. #define DEFINE_LITERAL(N) int operator""_u##N(const char* s)...
Paweł Bylica's user avatar
3 votes
2 answers
247 views

I frequently need to create string manipulation functions in C++. My APIs tend to be written to accept std::basic_string<T> (effectively), but I also want to accept std::basic_string_view<T&...
J.S. Hughes's user avatar
9 votes
1 answer
473 views

I am learning about user defined literals and I wrote the following program that works with gcc and msvc but clang rejects it. Live demo #include <array> template<std::size_t N> struct ...
user avatar
0 votes
0 answers
100 views

Since the Standard Library never defines literal operators in the root std namespace, what is the danger of having user defined operators not starting with underscore?
thebugger's user avatar
  • 235
3 votes
1 answer
463 views

I'm trying to define a user-defined string literal template. Shouldn't that code snippet work? / Why doesn't it work? template<char...> constexpr int operator ""_x () { return 0; } ...
grekd's user avatar
  • 43
7 votes
2 answers
405 views

Consider the following example provided by Aykhan Hagverdili: #include <string> using std::operator""s; #define s foobar auto s = "hello world"s; Some compilers would ...
Alex Guteniev's user avatar
0 votes
1 answer
53 views

I have a class with copy constructor and copy assign operator deleted. Move constructor amd move-assign operator are present. It also defines an operator<<: struct S { S(std::size_t s) {} ...
PaperBirdMaster's user avatar
5 votes
2 answers
811 views

If I'm not mistaken, the arguments for a user defined literal are always known at compile time. In C++20 you can force functions to execute at compile time using consteval so that throw generates a ...
Benjamin Buch's user avatar
1 vote
2 answers
147 views

Literals don't seem to interplay well with preprocessor macros. For example, I have this preprocessor definition CONFIG_FADE_DELAY_MS that I want to translate to std::chrono::milliseconds. But the ms ...
glades's user avatar
  • 5,374
1 vote
1 answer
275 views

At [over.literal] I read, in the list of examples, that double operator""_Bq(long double); is valid, whereas double operator"" _Bq(long double); is ill-formed, which is ...
Enlico's user avatar
  • 30.3k

15 30 50 per page
1
2 3 4 5
12