Is it possible to overload the basic types in C++?

Is it possible to implement an overload of the base type in C++ ?
For example, to overload the comparison operators < > == for char/char*.
I need it to comfortably work with pattern tree, not to remake a char*.
September 19th 19 at 00:30
4 answers
September 19th 19 at 00:32
Solution
No, you cannot. In your case, you can write your own comparator and pass it to a template parameter in your tree.
If it does not support custom Comparators, add support, it is very useful.
thanks for the reply.

how to add support for custom Comparators, but I do not really understand. - Keaton_Hilpert commented on September 19th 19 at 00:35
: Add in the template the possibility of using lambda functions without the seizure as one of the options. The function should return a bool and take two parameters. And Yes, working with C strings in C++ in most cases similar to riding a bike without pedals. - Erling_Hansen79 commented on September 19th 19 at 00:38
Thank you.
More on the bike Bareback. - Keaton_Hilpert commented on September 19th 19 at 00:41
September 19th 19 at 00:34
Solution
Just expand the response MiiNiPaa.

Add support of template Comparators can be as follows:
template< typename item_t, template< typename > class item_traits >
class item_processor{
private:
 typedef item_traits<item_t> traits_t;
...
};</item_t>


Raising the second template parameter is a template template parameter. :)
From David Vandervud for this reason it was even so written: "Because the parameter of a template template parameter not used, its name can be omitted".
Such a record suggests that at instantiation or specialization of a template in its announcement is expected only the name of the template, not its instantiation.

Use this case like so:
template< typename target_t >
class traits_less;

...

item_processor<char, traits_less> char_processor;</char>


All Comparators STL have one template parameter. Thus, their use becomes valid as a parameter for item_processor. At the same time, and your comparator in this system to add not be a problem.
September 19th 19 at 00:36
It's definitely a bad idea. If you want you can compare strings, use std::string.
There is TK.
Must be the wood and char*.
And remake the whole tree because the two operations do not see the point. - Keaton_Hilpert commented on September 19th 19 at 00:39
: then so www.cplusplus.com/reference/cstring/strcmp - Erling_Hansen79 commented on September 19th 19 at 00:42
strcmp this is clear.
but if you use it directly, you will not be able to use the template tree.
but, if you overload > < == (and then use this strcmp), then the pattern tree is not necessary to touch will.

the whole point in working with the pattern without crutches. - Keaton_Hilpert commented on September 19th 19 at 00:45
The best option to do so, as advised . This is how standard containers. For example std::set - Keaton_Hilpert commented on September 19th 19 at 00:48
September 19th 19 at 00:38
Overloading it is possible, but what will come of this.
UPD
impossible.
at least "head" - Keaton_Hilpert commented on September 19th 19 at 00:41

Find more questions by tags ProgrammingOOPC++