c++ - How do I require const_iterator semantics in a template function signature? -
I am creating a constructor which will take a pair of input iterator. I want to do the method signature as compile-time code:
DataObject :: DataObject (const char * start, const char * end)
However, I have not found some examples of this. For example, the range constructor of my STL implementation has been defined for vector
:
template
There is no compile-time const
guarantees iterator_category
/ iterator_traits & lt; & Gt; There is nothing related to
const
, either.
Is there any way to guarantee that the collar that I can not modify the input data?
edit, 2010-02-03 16:35 UTC
For example, how would I like to use the function, depending on the function signature , I want to be able to pass a pair of points to the char *
and the data they point to will not be modified.
I was hoping that I can not build a pair of pointers for the guarantee of consultant semantics. I can be forced to pay the template tax in this case. is.
You can create a dummy function just like your template is four * cons
Calling with Points If your template tries to modify your goal, then your dummy function will not be compiled. After this, you can put the dummy in. #ifndef NDEBUG
Guard to get it out of the release build.
Comments
Post a Comment