1

Topic: forward and specialization of sample function

Greetings! There is some macro, which   and  for them. All with a macro well except that there is a problem at usage of the metafunctional code. An example: #include <iostream> namespace myns {template <typename E> E enum_cast (const char *, bool ok = true);//forward enum class myenum0 {e0, e1}; template <> myenum0 enum_cast (const char *, bool) {return myenum0 {};}}//ns myns template <typename E> E enum_cast (const char *, bool ok = true);//forward enum class myenum1 {e0, e1}; template <> myenum1 enum_cast (const char *, bool) {return myenum1 {};} int main (int, char ** argv) {myns:: myenum0 e0 = enum_cast <myns:: myenum0> (argv [0]);//here, for some reason, ADL does not work myenum1 e1 = enum_cast <myenum1> (argv [0]);} Let's receive: undefined reference to ` myns:: myenum0 enum_cast <myns:: myenum0> (char const *, bool) ' the macro does not know  in which it is used. And ADL for some reason does not work... How to win? Thanks.

2

Re: forward and specialization of sample function

X> and ADL for some reason does not work... Probably because it not function argument but template parameter?

3

Re: forward and specialization of sample function

Hello, niXman, you wrote: X>> and ADL for some reason does not work... X> probably because it not function argument but template parameter? ADL is when function search is carried out in  types of arguments

4

Re: forward and specialization of sample function

Hello, uzhas, you wrote: U> ADL is when function search is carried out in  types of arguments I and assumed. As to overcome? To change a template so that accepted also argument, and to use type so?: auto e = enum_cast (myns:: myenum0 {}, str); what else variants are?

5

Re: forward and specialization of sample function

Hello, niXman, you wrote: X> what else variants are? It is possible to go through : https://ideone.com/fJMib2

6

Re: forward and specialization of sample function

Hello, niXman, you wrote: X> how to win? Declare in one namespace Than further subjects it is necessary to struggle with C "pluses" ++ instead of the real task more

7

Re: forward and specialization of sample function

Hello, uzhas, you wrote: U> it is possible to go through : https://ideone.com/fJMib2 yes, but the macro does not know, whether it is used in , and if in - that in what... Or to do in two stages:  , and  all remaining.

8

Re: forward and specialization of sample function

Hello, kov_serg, you wrote: _> Than further subjects it is necessary to struggle with C "pluses" ++ instead of the real task more and still it is necessary to guzzle, , to sleep and strike (to place on priorities)... But somehow with it live

9

Re: forward and specialization of sample function

Hello, niXman, you wrote: _>> Than further subjects it is necessary to struggle with C "pluses" ++ instead of the real task X> more and still it is necessary to guzzle, , to sleep and strike (to place on priorities)... But somehow with it live Business in not in problems, and in their origin. These ourselves created and now heroically them we overcome. https://habrahabr.ru/post/218229/

10

Re: forward and specialization of sample function

I have a library of generation of a meta information, arithmetical operators and the operator of an output for enum' in style boost (and depending from boost) which I long use. Free are supported enum, enum class, enum' and enclosed in a class. Also is MPL the adapter for enum class. Probably you should use simply to it, instead of to write the. If, of course, you do not do it for the sake of art. Hello, niXman, you wrote: X> greetings! X> there is some macro, which   and  for them.

11

Re: forward and specialization of sample function

Hello, swingus, you wrote: S> I have a library of generation of a meta information, arithmetical operators and the operator of an output for enum' in style boost (and depending from boost) which I long use. Free are supported enum, enum class, enum' and enclosed in a class. Also is MPL the adapter for enum class. Probably you should use simply to it, instead of to write the. If, of course, you do not do it for the sake of art. And the reference can be seen?

12

Re: forward and specialization of sample function

I took a bite from the project and added small test set. The link I Checked only on VC ++ 2017 therefore as passed with char const * on std:: string_view, and compiled for VC ++ clang toolset - very old version clang. If there will be questions or something goes not so - address. X> hello, niXman, you wrote: X> and a reference it is possible to see?