C++: can i create my own style type?

on C\C++ the strings are collected\added between mark quotions(").
can i create my own style between '#'?
# is too valuable/useful. You could create a define for '$' , though, probably.
how can i do it?
...Why fight the language? What does it accomplish?

But you can make use of user-defined string literals (since C++11), but I don't think this is really what you're asking.
https://en.cppreference.com/w/cpp/language/user_literal (Scroll down to Examples)

@icy1 Nope, macro names have the same rules as variable names (alphanumeric or underscores, and no leading numbers).
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <string>

using namespace std;

#define $(...) #__VA_ARGS__

int main() 
{
    string s($(hello));
    cout << s << ' ' << $(there!) << '\n';
}


hello there!
Oh, that's a GCC extension. Okay, you got me there.

Edit: Okay so Visual Studio seems to be OK with it as well. And clang allows weird emoji identifiers.
But that's all non-standard :) However, point taken, it works.
Last edited on
Ganado: i don't have nothing against the C\C++.. i'm doing a project for learn much more ;)
i'm learning using tokens for my language. my language will be converted to C++.
i'm doing several things for be easy to use.
icy1: i need more like:
#23/12/28#
theres like 3 arguments(day, month and year).
is what i need.
#23/12/28#

Do you mean in the source code itself, or parsing it from a file or stdin?
The former is not possible, the latter certainly is.
Last edited on
user-defined literals don't accept 3 arguments?
(C++ 14)
Last edited on
my language will be converted to C++.

If you're converting to C++ then why do you need to create your own style? Convert to whatever C++ requires.
indeed, write your own language in MyFile.own or whatever, then use a parser with a code generator class to convert your tokens into C++ tokens.
yes. thank you so much for all
Topic archived. No new replies allowed.