
Any chance of a boost implementation for is_literal_type? Robert Ramey

Rodrigo Madera wrote:
On Thu, Feb 28, 2013 at 6:32 AM, John Maddock <boost.regex@virgin.net>wrote:
Any chance of a boost implementation for is_literal_type?
Robert,
Can you give an example of how it's usage would be?
Sort an interesting question. I'm imagining something like: template<class T> int f(T const & t){ if(std::is_lteral_type<T>) return t; else return g(t); // do some sort of conversion } in order to skip instantiation/invokation of g when it isn't necessary in this example.
I suspect that you may want something illegal in C++.it's part of the standard - see section 20.9.2 - so ...
- any C++ not delivered with an implementation is not a conforming C++ compiler. - no C++ compilers (as far as I know) are delivered with this type trait - hence, there are no conforming C++ compilers available. What is even more odd to me, is that it seems that a type trait required by the standard library can't be implemented by the language as specified by the standard. I'm wondering if I should go to one of these standards meeetings sometime. Robert Ramey
Rodrigo
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Can you give an example of how it's usage would be?
Sort an interesting question. I'm imagining something like:
template<class T> int f(T const & t){ if(std::is_lteral_type<T>) return t; else return g(t); // do some sort of conversion }
in order to skip instantiation/invokation of g when it isn't necessary in this example.
That wouldn't work - just because a type is a literal type doesn't mean that it's convertible to int. In that particular case wouldn't is_convertible do? John.

John Maddock wrote:
Can you give an example of how it's usage would be?
Sort an interesting question. I'm imagining something like:
template<class T> int f(T const & t){ if(std::is_lteral_type<T>) return t; else return g(t); // do some sort of conversion }
in order to skip instantiation/invokation of g when it isn't necessary in this example.
That wouldn't work - just because a type is a literal type doesn't mean that it's convertible to int. In that particular case wouldn't is_convertible do?
lol - I knew this would happen. It's very difficult to make a quick short answer to a question such as this. I'm sure I could spend some time trying to craft a better example. The context in which the question occurred to me is way too complicated to paste in here. So I'll turn the tables. If there is no use case for it, why is it in the standard? What use case did those who wrote the standard have in mind? I'm all ears. Robert Ramey

On Mar 2, 2013 6:02 PM, "Robert Ramey" wrote:
- any C++ not delivered with an implementation is not a conforming C++ compiler. - no C++ compilers (as far as I know) are delivered with this type trait - hence, there are no conforming C++ compilers available.
Are you sure? I know it's in libstdc++ and I bet libc++ has it too.
What is even more odd to me, is that it seems that a type trait required by the standard library can't be implemented by the language as specified by the standard.
There are several such traits. Traits tell you properties of a type, some properties cannot be detected without compiler "magic", and the library trait is the standard interface to that magic. What would you prefer, an operator like noexcept? Why would that be better?
participants (4)
-
John Maddock
-
Jonathan Wakely
-
Robert Ramey
-
Rodrigo Madera