about enable_if for member functions
пометка
Сообщения 1 - 10 из 592 - Свернуть все
/groups/adfetch?adid=M6gOlBIAAADRBLs382qykWJ9R0ksTobtA-seRgWUrY1Re68AkUbKNw
about enable_if for member functions - Отправлять мне обновления по электронной почте  
Сообщение будет отправлено в группу Usenet. Когда Вы отправляете сообщения в такие группы, Ваш адрес электронной почты публикуется в Интернете.
Ваш ответ не был отправлен.
Сообщение отправлено успешно.
 
Автор:
Кому:
Копия:
В ответ на:
Добавить копию | Добавить заголовок "В ответ на" | Изменить тему
Тема:
Утверждение:
Для подтверждения введите символы, изображенные на картинке ниже, или цифры, которые вы услышите, нажав на значок упрощенного доступа. Слушайте и вводите услышанные числа
 
1.  Yutaka Leon Suematsu  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 1 апр 2005, 12:27
Автор: "Yutaka Leon Suematsu" <yut...@atr.jp>
Дата: Fri, 1 Apr 2005 18:27:23 +0900
Местное время: Пт. 1 апр 2005 12:27
Тема: [Boost-users] about enable_if for member functions
Dear booster,

I have a question related to enable_if. I would like to enable or disable
some member functions from a template class, but enable_if is -not enable-
to do it :-)

Here is the code.

template <class T>
class A
{
...
      enable_if< boost::is_arithmetic<T>, void > :: type  f1()
      {
            ...
      }

};

In class A, I want to define function f1 only if the template parameter is
arithmetic. It works fine except when the parameter is not arithmetic. I
have a compile error "error C2039: 'type' : is not a member of
'boost::enable_if<Cond,T>'" (Working with VC7.1, and boost 3.12)

Thank you in advance for any suggestions and help.

Sincerely yours,

Yutaka Leon Suematsu

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
2.  Jaakko Järvi  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 1 апр 2005, 20:25
Автор: Jaakko Järvi <jaja...@cs.indiana.edu>
Дата: Fri, 1 Apr 2005 11:25:55 -0600
Местное время: Пт. 1 апр 2005 20:25
Тема: Re: [Boost-users] about enable_if for member functions
Hello Yutaka,

The problem is that T is not a template parameter of you function f1.
It is a template parameter of the class A. So when the class A
is instantiated with some type that is not arithmetic, say void*,
it is as if you would directly write a function:

enable_if<boost::is_arithmetic<void*>, void>::type

which is

enable_if<false, void>::type

which is an error, since enable_if<false,void> is an empty class.

You can write your code as follows to make enable_if work, but it may
not be a solution that works:

class A
{
...
       template <class T>
       enable_if< boost::is_arithmetic<T>, void > :: type  f1()
       {
             ...
       }

};

Also, here you need to explicitly instantiate f1 as

A a;

a.f1<int>();

Best, Jaakko Järvi

On Apr 1, 2005, at 3:27 AM, Yutaka Leon Suematsu wrote:

-- Jaakko Järvi, Assistant Professor
-- Texas A&M University, Computer Science
-- ja...@cs.tamu.edu

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
3.  Yutaka Leon Suematsu  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 4 апр 2005, 15:33
Автор: "Yutaka Leon Suematsu" <yut...@atr.jp>
Дата: Mon, 4 Apr 2005 21:33:13 +0900
Местное время: Пн. 4 апр 2005 15:33
Тема: [Boost-users] Re: about enable_if for member functions
Hello Jaakko,

Thank you for your reply.

> The problem is that T is not a template parameter of you function f1.
> It is a template parameter of the class A.

I got it.

> class A
> {
> ...
>        template <class T>
>        enable_if< boost::is_arithmetic<T>, void > :: type  f1()
>        {
>              ...
>        }
> };
> Also, here you need to explicitly instantiate f1 as

> A a;
> a.f1<int>();

I tried this way too. Although I wanted to have only one interface, I guess
it the best possibility I have now.

Thanks a lot,

Yutaka Leon Suematsu

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
4.  Jonathan Turkanis  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 5 апр 2005, 00:39
Автор: "Jonathan Turkanis" <techn...@kangaroologic.com>
Дата: Mon, 4 Apr 2005 15:39:33 -0600
Местное время: Вт. 5 апр 2005 00:39
Тема: [Boost-users] Re: about enable_if for member functions

Yutaka Leon Suematsu wrote:
> Dear booster,

> I have a question related to enable_if. I would like to enable or
> disable some member functions from a template class, but enable_if is
> -not enable- to do it :-)

The usual way to do this, since enable_if is not applicable, is to implement the
function in an optional base class, and use mpl::if or eval_if to derive from
the base only if you want the function enabled.

Jonathan

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
[Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)? - Отправлять мне обновления по электронной почте  
1.  John Maddock  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 1 апр 2005, 12:58
Автор: "John Maddock" <j...@johnmaddock.co.uk>
Дата: Fri, 1 Apr 2005 10:58:23 +0100
Местное время: Пт. 1 апр 2005 12:58
Тема: Re: [Boost-users] [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?

> I would like to know if it's possible to assign an alias/name to a
> sub-expression.  When using short regex there is no problem nor confusion
> but when using a long regex then I get lost looking at the correct index
> to use.  It would be much easier if I can assign an alias.

> So, instead  to use a regex like this:

> "\s*(\d+)\s+(\d+)\s+(\d+)\s+"

> I would like to be able to use something like:

> "\s*([$VALUE1]\d+)\s+([$VALUE2]\d+)\s+([$VALUE3]\d+)\s+"

> I don't know if this feature exists in regex but I haven't found it but
> maybe I dind't know where to find...

No that's not supported, but don't forget that you can always use
non-marking parenthesis to avoid throwing out too many fields.

John.

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
2.  jordi  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 5 апр 2005, 12:00
Автор: jordi <jord...@hotmail.com>
Дата: Tue, 05 Apr 2005 11:00:53 +0200
Местное время: Вт. 5 апр 2005 12:00
Тема: [Boost-users] Re: [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?

John Maddock wrote:
>> I would like to know if it's possible to assign an alias/name to a
>> sub-expression.  When using short regex there is no problem nor

> No that's not supported, but don't forget that you can always use
> non-marking parenthesis to avoid throwing out too many fields.

> John.

I already use non-marking parenthesis but when using a long regex it's
very difficult to decide which is the correct index to define the
subexpression to use.  Furthermore, when using "conditional
expressiones" in the format strings the difficulties are even more
obvious...

Thanks anyway for your reply,

Jordi

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
3.  Stuart Dootson  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 5 апр 2005, 12:20
Автор: Stuart Dootson <stuart.doot...@gmail.com>
Дата: Tue, 5 Apr 2005 10:20:00 +0100
Тема: Re: [Boost-users] Re: [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?
On Apr 5, 2005 10:00 AM, jordi <jord...@hotmail.com> wrote:

Jordi - something like Regex Coach (http://www.weitz.de/regex-coach/)
makes it a lot easier to work out what match indices to use for the
different captures in your regular expressions...

Stuart Dootson
_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
4.  jordi  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 6 апр 2005, 13:49
Автор: jordi <jord...@hotmail.com>
Дата: Wed, 06 Apr 2005 12:49:46 +0200
Местное время: Ср. 6 апр 2005 13:49
Тема: [Boost-users] Re: [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?

> Jordi - something like Regex Coach (http://www.weitz.de/regex-coach/)
> makes it a lot easier to work out what match indices to use for the
> different captures in your regular expressions...

I'm already using Regex Coach because someone in this group suggested it
to check my regex.  I think it's a very great tool!.

I have just realized there is the option to get the index in the
"Hightlight" section but I don't know how to get an index greater than
10... (anyone knows how to do that?)

Thanks,

Jordi

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
5.  Stuart Dootson  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 6 апр 2005, 14:37
Автор: Stuart Dootson <stuart.doot...@gmail.com>
Дата: Wed, 6 Apr 2005 12:37:38 +0100
Местное время: Ср. 6 апр 2005 14:37
Тема: Re: [Boost-users] Re: [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?
On Apr 6, 2005 11:49 AM, jordi <jord...@hotmail.com> wrote:

I thinkn that might have been my suggestion :-)

Hmmm - 10 captures!!!

The only thing I can suggest for indices > 10 is contacting the tool
maintainer through the mailing list
(http://common-lisp.net/mailman/listinfo/regex-coach). It says
something about feature requests there....

Stuart Dootson
_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.
6.  jordi  
Просмотреть профиль   Перевести на Переведено (просмотреть оригинал)
 Дополнительные параметры 5 апр 2005, 12:23
Автор: jordi <jord...@hotmail.com>
Дата: Tue, 05 Apr 2005 11:23:26 +0200
Местное время: Вт. 5 апр 2005 12:23
Тема: [Boost-users] Re: [Regex] Is it possible to assign an alias to a subexpression (to use later instead of its index)?

John Maddock wrote:
>> I would like to know if it's possible to assign an alias/name to a
>> sub-expression.  When using short regex there is no problem nor

> No that's not supported, but don't forget that you can always use
> non-marking parenthesis to avoid throwing out too many fields.

> John.

I already use non-marking parenthesis but when using a long regex it's
very difficult to decide which is the correct index to define the
subexpression to use.  Furthermore, when using "conditional
expressiones" in the format strings the difficulties are even more
obvious...

Thanks anyway for your reply,

Jordi

_______________________________________________
Boost-users mailing list
Boost-us...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


    Переслать  
Чтобы отправлять сообщения, сначала необходимо Войти.
Чтобы отправлять сообщения, сначала необходимо присоединиться к группе.
Перед отправкой сообщения обновите свой псевдоним на странице Настройки подписки.
У вас нет разрешения на отправку сообщений.

Создать группу - Группы Google - Главная страница Google - Условия предоставления услуг - Политика конфиденциальности
©2010 Google