[boost][mpl] Detect a type sequence type

Hi, I am writing some functions and classes that accept a sequence of type ( boost::mpl::vector/list currently) as template parameter. I'm looking for a way to enhance type checking by making sure the provided types are... type sequences. I didn't find anything relevant in standard or boost type_trait libraries. So far, I'm guessing there is no way to check that, mainly because such types would be template instances, which make checking this like checking if a type is an instance of a template which is impossible right now (as far as I know anyway). My question is: what are possible ways to enhance type checking on type sequence types? I know some boost developers around here make great efforts to make sure their meta programming libraries make early and good error reporting so maybe they have a solution? PS: I'm using Visual Studio 2012 so I can't use variadic template yet ;___; (can't rely on the CTP) Joel Lamotte

On Fri, Dec 7, 2012 at 8:15 AM, Klaim - Joël Lamotte
Hi,
I am writing some functions and classes that accept a sequence of type ( boost::mpl::vector/list currently) as template parameter. I'm looking for a way to enhance type checking by making sure the provided types are... type sequences.
I didn't find anything relevant in standard or boost type_trait libraries.
So far, I'm guessing there is no way to check that, mainly because such types would be template instances, which make checking this like checking if a type is an instance of a template which is impossible right now (as far as I know anyway).
My question is: what are possible ways to enhance type checking on type sequence types? I know some boost developers around here make great efforts to make sure their meta programming libraries make early and good error reporting so maybe they have a solution?
PS: I'm using Visual Studio 2012 so I can't use variadic template yet ;___; (can't rely on the CTP)
Joel Lamotte
Is mpl::is_sequence what you're looking for? - Jeff

On Fri, Dec 7, 2012 at 5:40 PM, Jeffrey Lee Hellrung, Jr. < jeffrey.hellrung@gmail.com> wrote:
Is mpl::is_sequence what you're looking for?
- Jeff
How did I miss that O___O Thanks it's exactly what I was looking for but not at the right section of the doc. It is supposed to work only with MPL containers, isn't it? Joel Lamotte

On Fri, Dec 7, 2012 at 8:57 AM, Klaim - Joël Lamotte
On Fri, Dec 7, 2012 at 5:40 PM, Jeffrey Lee Hellrung, Jr. < jeffrey.hellrung@gmail.com> wrote:
Is mpl::is_sequence what you're looking for?
- Jeff
How did I miss that O___O Thanks it's exactly what I was looking for but not at the right section of the doc. It is supposed to work only with MPL containers, isn't it?
Yes, I believe so, but there is an extension framework within Boost.MPL to enable other types to be MPL-compatible sequences, if you needed that. If you wanted to actually be more restrictive, I believe you might be able to retrieve the dispatch tag of the MPL sequence and check that it's a vector_tag, list_tag, etc. (I'm writing that all from fuzzy memory so I don't know if I have the terminology and names right). And I think if a type is not an MPL sequence, it returns some dummy "n/a" tag. Check the documentation and/or header files (specifically is_sequence.hpp, probably). - Jeff
participants (2)
-
Jeffrey Lee Hellrung, Jr.
-
Klaim - Joël Lamotte