This file is indexed.

/usr/include/vigra/numpy_array_converters.hxx is in libvigraimpex-dev 1.10.0+git20160211.167be93+dfsg-2+b5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
/************************************************************************/
/*                                                                      */
/*       Copyright 2009 by Ullrich Koethe and Hans Meine                */
/*                                                                      */
/*    This file is part of the VIGRA computer vision library.           */
/*    The VIGRA Website is                                              */
/*        http://hci.iwr.uni-heidelberg.de/vigra/                       */
/*    Please direct questions, bug reports, and contributions to        */
/*        ullrich.koethe@iwr.uni-heidelberg.de    or                    */
/*        vigra@informatik.uni-hamburg.de                               */
/*                                                                      */
/*    Permission is hereby granted, free of charge, to any person       */
/*    obtaining a copy of this software and associated documentation    */
/*    files (the "Software"), to deal in the Software without           */
/*    restriction, including without limitation the rights to use,      */
/*    copy, modify, merge, publish, distribute, sublicense, and/or      */
/*    sell copies of the Software, and to permit persons to whom the    */
/*    Software is furnished to do so, subject to the following          */
/*    conditions:                                                       */
/*                                                                      */
/*    The above copyright notice and this permission notice shall be    */
/*    included in all copies or substantial portions of the             */
/*    Software.                                                         */
/*                                                                      */
/*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND    */
/*    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES   */
/*    OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND          */
/*    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT       */
/*    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,      */
/*    WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING      */
/*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR     */
/*    OTHER DEALINGS IN THE SOFTWARE.                                   */
/*                                                                      */
/************************************************************************/

#ifndef VIGRA_NUMPY_ARRAY_CONVERTERS_HXX
#define VIGRA_NUMPY_ARRAY_CONVERTERS_HXX

#include "numpy_array.hxx"
#include "metaprogramming.hxx"
#include <boost/python.hpp>
#include <boost/python/to_python_converter.hpp>
#include <boost/python/raw_function.hpp>
#include <set>
#include <type_traits>

namespace vigra {

template <class Array>
PyObject * returnNumpyArray(Array const & a)
{
    PyObject * pa = a.pyObject();
    if(pa == 0)
        PyErr_SetString(PyExc_ValueError, "returnNumpyArray(): Conversion to Python failed, array has no data.");
    else
        Py_INCREF(pa);
    return pa;
}

VIGRA_EXPORT std::set<std::string> & exportedArrayKeys();

template <class ArrayType>
struct NumpyArrayConverter {};

template <unsigned int N, class T, class Stride>
struct NumpyArrayConverter<NumpyArray<N, T, Stride> >
{
    typedef NumpyArray<N, T, Stride> ArrayType;
    typedef typename ArrayType::ArrayTraits ArrayTraits;

    NumpyArrayConverter();

    static void* convertible(PyObject* obj);

    // from Python
    static void construct(PyObject* obj,
        boost::python::converter::rvalue_from_python_stage1_data* data);

    // to Python
    static PyObject* convert(ArrayType const& a)
    {
        return returnNumpyArray(a);
    }
};

template <unsigned int N, class T, class Stride>
NumpyArrayConverter<NumpyArray<N, T, Stride> >::NumpyArrayConverter()
{
    using namespace boost::python;

    converter::registration const * reg = converter::registry::query(type_id<ArrayType>());

    // register the to_python_converter only once
    // FIXME: I'm not sure if this is correct.
    if(!reg || !reg->rvalue_chain)
    {
        to_python_converter<ArrayType, NumpyArrayConverter>();
    }
    converter::registry::insert(&convertible, &construct, type_id<ArrayType>());
}

template <unsigned int N, class T, class Stride>
void * NumpyArrayConverter<NumpyArray<N, T, Stride> >::convertible(PyObject* obj)
{
    bool isCompatible = obj == Py_None || ArrayType::isStrictlyCompatible(obj);
    // std::cerr << "compatible for " << typeid(NumpyArray<N, T, Stride>).name() << ": " << isCompatible << "\n";
    return isCompatible
             ? obj
             : 0;
}

// from Python
template <unsigned int N, class T, class Stride>
void NumpyArrayConverter<NumpyArray<N, T, Stride> >::construct(PyObject* obj,
                   boost::python::converter::rvalue_from_python_stage1_data* data)
{
    void* const storage =
        ((boost::python::converter::rvalue_from_python_storage<ArrayType>* ) data)->storage.bytes;

    ArrayType * array = new (storage) ArrayType();
    if(obj != Py_None)
        array->makeReferenceUnchecked(obj);

    data->convertible = storage;
}

template <unsigned int N, class T, class Stride>
struct NumpyArrayConverter<MultiArrayView<N, T, Stride> >
: public NumpyArrayConverter<NumpyArray<N, T, Stride> >
{
    typedef NumpyArrayConverter<NumpyArray<N, T, Stride> > BaseType;
    typedef MultiArrayView<N, T, Stride> ArrayType;

    NumpyArrayConverter()
    {
        using namespace boost::python;
        converter::registry::insert(&BaseType::convertible, &BaseType::construct,
                                    type_id<ArrayType>());
    }
};

template <class Iter, class End>
struct RegisterNumpyArrayConverters
{
    static void exec()
    {
        typedef typename UnqualifiedType<typename boost::mpl::deref<Iter>::type>::type Type;
        NumpyArrayConverter<Type>();
        RegisterNumpyArrayConverters<typename boost::mpl::next<Iter>::type, End>::exec();
    }
};

template <class End>
struct RegisterNumpyArrayConverters<End, End>
{
    static void exec()
    {}
};

template <class Typelist>
void registerNumpyArrayConverters(Typelist)
{
    RegisterNumpyArrayConverters<typename boost::mpl::begin<Typelist>::type,
                                 typename boost::mpl::end<Typelist>::type >::exec();
}

template <class FN>
FN registerConverters(FN f)
{
    registerNumpyArrayConverters(boost::python::detail::get_signature(f));
    return f;
}

namespace detail {

template <class T>
struct TypeName;

template <class T>
struct TypeName<Singleband<T>>
: public TypeName<T>
{};

template <class T>
struct TypeName<Multiband<T>>
: public TypeName<T>
{};

template <class T, int N>
struct TypeName<TinyVector<T, N>>
: public TypeName<T>
{};

template <>
struct TypeName<void>
{
    static std::string name() {
        return std::string("void");
    }
    static std::string sized_name() {
        return std::string("void");
    }
};

template <>
struct TypeName<bool>
{
    static std::string name() {
        return std::string("bool");
    }
    static std::string sized_name() {
        return std::string("bool8");
    }
};

#define VIGRA_SIGNED_INT_NAME(type) \
template <> \
struct TypeName<type> \
{ \
    static std::string name() { \
        return std::string(#type); \
    } \
    static std::string sized_name() { \
        return std::string("int") + std::to_string(sizeof(type)*8); \
    } \
};

VIGRA_SIGNED_INT_NAME(signed char)
VIGRA_SIGNED_INT_NAME(short)
VIGRA_SIGNED_INT_NAME(int)
VIGRA_SIGNED_INT_NAME(long)
VIGRA_SIGNED_INT_NAME(long long)

#define VIGRA_UNSIGNED_INT_NAME(type) \
template <> \
struct TypeName<type> \
{ \
    static std::string name() { \
        return std::string(#type); \
    } \
    static std::string sized_name() { \
        return std::string("uint") + std::to_string(sizeof(type)*8); \
    } \
};

VIGRA_UNSIGNED_INT_NAME(unsigned char)
VIGRA_UNSIGNED_INT_NAME(unsigned short)
VIGRA_UNSIGNED_INT_NAME(unsigned int)
VIGRA_UNSIGNED_INT_NAME(unsigned long)
VIGRA_UNSIGNED_INT_NAME(unsigned long long)

#define VIGRA_FLOAT_NAME(type) \
template <> \
struct TypeName<type> \
{ \
    static std::string name() { \
        return std::string(#type); \
    } \
    static std::string sized_name() { \
        return std::string("float") + std::to_string(sizeof(type)*8); \
    } \
};

VIGRA_FLOAT_NAME(float)
VIGRA_FLOAT_NAME(double)
VIGRA_FLOAT_NAME(long double)

#undef VIGRA_SIGNED_INT_NAME
#undef VIGRA_UNSIGNED_INT_NAME
#undef VIGRA_FLOAT_NAME

template <class T = void>
struct ExportDoc
{
    static char const * exec(char const *) { return 0; }
};

template <>
struct ExportDoc<void>
{
    static char const * exec(char const * h) { return h; }
};

} // namespace detail

} // namespace vigra

namespace boost { namespace python {

// Note: Due to a bug in boost::python::docstring_options,
//       the documentation must always be associated with the
//       *last* overload, making the functors defined below a
//       bit more complicated.

#define VIGRA_PYTHON_MULTITYPE_FUNCTOR(functor_name, function) \
template <class T> \
struct functor_name##Impl \
{ \
    static void def(const char * pythonName) \
    { \
        boost::python::docstring_options doc(false); \
        boost::python::def(pythonName, vigra::registerConverters(&function<T>)); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args) \
    { \
        boost::python::docstring_options doc(false); \
        boost::python::def(pythonName, vigra::registerConverters(&function<T>), args); \
    } \
    \
    static void def(const char * pythonName, char const * help) \
    { \
        if(help) \
            boost::python::def(pythonName, \
                         vigra::registerConverters(&function<T>), help); \
        else \
            def(pythonName); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args, char const * help) \
    { \
        if(help) \
            boost::python::def(pythonName, \
                         vigra::registerConverters(&function<T>), args, help); \
        else \
            def(pythonName, args); \
    } \
}; \
 \
template <> \
struct functor_name##Impl<void> \
{ \
    static void def(const char *) {} \
     \
    template <class A1> \
    static void def(const char *, A1 const &) {} \
     \
    template <class A1, class A2> \
    static void def(const char *, A1 const &, A2 const &) {} \
}; \
 \
template <class T1, \
          class T2 = void, \
          class T3 = void, \
          class T4 = void, \
          class T5 = void, \
          class T6 = void, \
          class T7 = void, \
          class T8 = void, \
          class T9 = void, \
          class T10 = void, \
          class T11 = void, \
          class T12 = void> \
struct functor_name \
: public boost::python::PythonMultidefFunctor \
{ \
    bool install_fallback_, show_python_signature_; \
    \
    functor_name() \
    : install_fallback_(false) \
    , show_python_signature_(true) \
    {} \
    \
    functor_name & installFallback() \
    { \
        install_fallback_ = true; \
        return *this; \
    } \
    \
    functor_name & noPythonSignature() \
    { \
        show_python_signature_ = false; \
        return *this; \
    } \
    \
    typedef boost::python::ArgumentMismatchMessage\
        <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Message; \
    typedef functor_name##Impl<T1 > F1; \
    typedef functor_name##Impl<T2 > F2; \
    typedef functor_name##Impl<T3 > F3; \
    typedef functor_name##Impl<T4 > F4; \
    typedef functor_name##Impl<T5 > F5; \
    typedef functor_name##Impl<T6 > F6; \
    typedef functor_name##Impl<T7 > F7; \
    typedef functor_name##Impl<T8 > F8; \
    typedef functor_name##Impl<T9 > F9; \
    typedef functor_name##Impl<T10> F10; \
    typedef functor_name##Impl<T11> F11; \
    typedef functor_name##Impl<T12> F12; \
    \
    void def(const char * pythonName) const \
    { \
        boost::python::docstring_options doc(false, false, false); \
        if(install_fallback_) \
            Message::def(pythonName); \
        F1 ::def(pythonName); \
        F2 ::def(pythonName); \
        F3 ::def(pythonName); \
        F4 ::def(pythonName); \
        F5 ::def(pythonName); \
        F6 ::def(pythonName); \
        F7 ::def(pythonName); \
        F8 ::def(pythonName); \
        F9 ::def(pythonName); \
        F10::def(pythonName); \
        F11::def(pythonName); \
        F12::def(pythonName); \
    } \
    \
    template <class Args> \
    void def(const char * pythonName, Args const & args) const \
    { \
        boost::python::docstring_options doc(false, false, false); \
        if(install_fallback_) \
            Message::def(pythonName); \
        F1 ::def(pythonName, args); \
        F2 ::def(pythonName, args); \
        F3 ::def(pythonName, args); \
        F4 ::def(pythonName, args); \
        F5 ::def(pythonName, args); \
        F6 ::def(pythonName, args); \
        F7 ::def(pythonName, args); \
        F8 ::def(pythonName, args); \
        F9 ::def(pythonName, args); \
        F10::def(pythonName, args); \
        F11::def(pythonName, args); \
        F12::def(pythonName, args); \
    } \
    \
    void def(const char * pythonName, const char * help) const \
    { \
        if(install_fallback_) \
            Message::def(pythonName); \
        boost::python::docstring_options doc(true, show_python_signature_, false); \
        F1 ::def(pythonName, detail::ExportDoc<T2 >::exec(help)); \
        F2 ::def(pythonName, detail::ExportDoc<T3 >::exec(help)); \
        F3 ::def(pythonName, detail::ExportDoc<T4 >::exec(help)); \
        F4 ::def(pythonName, detail::ExportDoc<T5 >::exec(help)); \
        F5 ::def(pythonName, detail::ExportDoc<T6 >::exec(help)); \
        F6 ::def(pythonName, detail::ExportDoc<T7 >::exec(help)); \
        F7 ::def(pythonName, detail::ExportDoc<T8 >::exec(help)); \
        F8 ::def(pythonName, detail::ExportDoc<T9 >::exec(help)); \
        F9 ::def(pythonName, detail::ExportDoc<T10>::exec(help)); \
        F10::def(pythonName, detail::ExportDoc<T11>::exec(help)); \
        F11::def(pythonName, detail::ExportDoc<T12>::exec(help)); \
        F12::def(pythonName, detail::ExportDoc<   >::exec(help)); \
    } \
    \
    template <class Args> \
    void def(const char * pythonName, Args const & args, char const * help) const \
    { \
        if(install_fallback_) \
            Message::def(pythonName); \
        boost::python::docstring_options doc(true, show_python_signature_, false); \
        F1 ::def(pythonName, args, detail::ExportDoc<T2 >::exec(help)); \
        F2 ::def(pythonName, args, detail::ExportDoc<T3 >::exec(help)); \
        F3 ::def(pythonName, args, detail::ExportDoc<T4 >::exec(help)); \
        F4 ::def(pythonName, args, detail::ExportDoc<T5 >::exec(help)); \
        F5 ::def(pythonName, args, detail::ExportDoc<T6 >::exec(help)); \
        F6 ::def(pythonName, args, detail::ExportDoc<T7 >::exec(help)); \
        F7 ::def(pythonName, args, detail::ExportDoc<T8 >::exec(help)); \
        F8 ::def(pythonName, args, detail::ExportDoc<T9 >::exec(help)); \
        F9 ::def(pythonName, args, detail::ExportDoc<T10>::exec(help)); \
        F10::def(pythonName, args, detail::ExportDoc<T11>::exec(help)); \
        F11::def(pythonName, args, detail::ExportDoc<T12>::exec(help)); \
        F12::def(pythonName, args, detail::ExportDoc<   >::exec(help)); \
    } \
};

#define VIGRA_PYTHON_MULTITYPE_FUNCTOR_NDIM(functor_name, function) \
template <class T, int FROM, int TO> \
struct functor_name##Impl \
{ \
    typedef functor_name##Impl type; \
     \
    static void def(const char * pythonName) \
    { \
        functor_name##Impl<T, FROM, FROM>::def(pythonName); \
        functor_name##Impl<T, FROM+1, TO>::def(pythonName); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args) \
    { \
        functor_name##Impl<T, FROM, FROM>::def(pythonName, args); \
        functor_name##Impl<T, FROM+1, TO>::def(pythonName, args); \
    } \
    \
    static void def(const char * pythonName, char const * help) \
    { \
        functor_name##Impl<T, FROM, FROM>::def(pythonName); \
        functor_name##Impl<T, FROM+1, TO>::def(pythonName, help); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args, char const * help) \
    { \
        functor_name##Impl<T, FROM, FROM>::def(pythonName, args); \
        functor_name##Impl<T, FROM+1, TO>::def(pythonName, args, help); \
    } \
}; \
\
template <class T, int N> \
struct functor_name##Impl<T, N, N> \
{ \
    typedef functor_name##Impl type; \
    \
    static void def(const char * pythonName) \
    { \
        boost::python::docstring_options doc(false); \
        boost::python::def(pythonName, vigra::registerConverters(&function<T, N>)); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args) \
    { \
        boost::python::docstring_options doc(false); \
        boost::python::def(pythonName, vigra::registerConverters(&function<T, N>), args); \
    } \
    \
    static void def(const char * pythonName, char const * help) \
    { \
        if(help) \
            boost::python::def(pythonName, \
                         vigra::registerConverters(&function<T, N>), help); \
        else \
            def(pythonName); \
    } \
    \
    template <class Args> \
    static void def(const char * pythonName, Args const & args, char const * help) \
    { \
        if(help) \
            boost::python::def(pythonName, \
                         vigra::registerConverters(&function<T, N>), args, help); \
        else \
            def(pythonName, args); \
    } \
}; \
\
template <int FROM, int TO> \
struct functor_name##Impl<void, FROM, TO> \
{ \
    static void def(const char *) {} \
    \
    template <class A1> \
    static void def(const char *, A1 const &) {} \
    \
    template <class A1, class A2> \
    static void def(const char *, A1 const &, A2 const &) {} \
}; \
\
template <int N> \
struct functor_name##Impl<void, N, N> \
{ \
    static void def(const char *) {} \
    \
    template <class A1> \
    static void def(const char *, A1 const &) {} \
    \
    template <class A1, class A2> \
    static void def(const char *, A1 const &, A2 const &) {} \
}; \
\
template <int FROM, int TO, \
          class T1, \
          class T2 = void, \
          class T3 = void, \
          class T4 = void, \
          class T5 = void, \
          class T6 = void, \
          class T7 = void, \
          class T8 = void, \
          class T9 = void, \
          class T10 = void, \
          class T11 = void, \
          class T12 = void> \
struct functor_name \
: public boost::python::PythonMultidefFunctor \
{ \
    bool install_fallback_, show_python_signature_; \
    \
    functor_name() \
    : install_fallback_(false) \
    , show_python_signature_(true) \
    { \
        static_assert(FROM <= TO, #functor_name ": dimension range empty (FROM > TO)"); \
    } \
    \
    functor_name & installFallback() \
    { \
        install_fallback_ = true; \
        return *this; \
    } \
    \
    functor_name & noPythonSignature() \
    { \
        show_python_signature_ = false; \
        return *this; \
    } \
    \
    typedef boost::python::ArgumentMismatchMessage\
        <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Message; \
    typedef functor_name##Impl<T1 , FROM, TO> F1; \
    typedef functor_name##Impl<T2 , FROM, TO> F2; \
    typedef functor_name##Impl<T3 , FROM, TO> F3; \
    typedef functor_name##Impl<T4 , FROM, TO> F4; \
    typedef functor_name##Impl<T5 , FROM, TO> F5; \
    typedef functor_name##Impl<T6 , FROM, TO> F6; \
    typedef functor_name##Impl<T7 , FROM, TO> F7; \
    typedef functor_name##Impl<T8 , FROM, TO> F8; \
    typedef functor_name##Impl<T9 , FROM, TO> F9; \
    typedef functor_name##Impl<T10, FROM, TO> F10; \
    typedef functor_name##Impl<T11, FROM, TO> F11; \
    typedef functor_name##Impl<T12, FROM, TO> F12; \
    \
    void def(const char * pythonName) const \
    { \
        boost::python::docstring_options doc(false, false, false); \
        if(install_fallback_) \
            Message::def(pythonName); \
        F1 ::def(pythonName); \
        F2 ::def(pythonName); \
        F3 ::def(pythonName); \
        F4 ::def(pythonName); \
        F5 ::def(pythonName); \
        F6 ::def(pythonName); \
        F7 ::def(pythonName); \
        F8 ::def(pythonName); \
        F9 ::def(pythonName); \
        F10::def(pythonName); \
        F11::def(pythonName); \
        F12::def(pythonName); \
    } \
    \
    template <class Args> \
    void def(const char * pythonName, Args const & args) const \
    { \
        boost::python::docstring_options doc(false, false, false); \
        if(install_fallback_) \
            Message::def(pythonName); \
        F1 ::def(pythonName, args); \
        F2 ::def(pythonName, args); \
        F3 ::def(pythonName, args); \
        F4 ::def(pythonName, args); \
        F5 ::def(pythonName, args); \
        F6 ::def(pythonName, args); \
        F7 ::def(pythonName, args); \
        F8 ::def(pythonName, args); \
        F9 ::def(pythonName, args); \
        F10::def(pythonName, args); \
        F11::def(pythonName, args); \
        F12::def(pythonName, args); \
    } \
    \
    void def(const char * pythonName, const char * help) const \
    { \
        if(install_fallback_) \
            Message::def(pythonName); \
        boost::python::docstring_options doc(true, show_python_signature_, false); \
        F1 ::def(pythonName, detail::ExportDoc<T2 >::exec(help)); \
        F2 ::def(pythonName, detail::ExportDoc<T3 >::exec(help)); \
        F3 ::def(pythonName, detail::ExportDoc<T4 >::exec(help)); \
        F4 ::def(pythonName, detail::ExportDoc<T5 >::exec(help)); \
        F5 ::def(pythonName, detail::ExportDoc<T6 >::exec(help)); \
        F6 ::def(pythonName, detail::ExportDoc<T7 >::exec(help)); \
        F7 ::def(pythonName, detail::ExportDoc<T8 >::exec(help)); \
        F8 ::def(pythonName, detail::ExportDoc<T9 >::exec(help)); \
        F9 ::def(pythonName, detail::ExportDoc<T10>::exec(help)); \
        F10::def(pythonName, detail::ExportDoc<T11>::exec(help)); \
        F11::def(pythonName, detail::ExportDoc<T12>::exec(help)); \
        F12::def(pythonName, detail::ExportDoc<   >::exec(help)); \
    } \
    \
    template <class Args> \
    void def(const char * pythonName, Args const & args, char const * help) const \
    { \
        if(install_fallback_) \
            Message::def(pythonName); \
        boost::python::docstring_options doc(true, show_python_signature_, false); \
        F1 ::def(pythonName, args, detail::ExportDoc<T2 >::exec(help)); \
        F2 ::def(pythonName, args, detail::ExportDoc<T3 >::exec(help)); \
        F3 ::def(pythonName, args, detail::ExportDoc<T4 >::exec(help)); \
        F4 ::def(pythonName, args, detail::ExportDoc<T5 >::exec(help)); \
        F5 ::def(pythonName, args, detail::ExportDoc<T6 >::exec(help)); \
        F6 ::def(pythonName, args, detail::ExportDoc<T7 >::exec(help)); \
        F7 ::def(pythonName, args, detail::ExportDoc<T8 >::exec(help)); \
        F8 ::def(pythonName, args, detail::ExportDoc<T9 >::exec(help)); \
        F9 ::def(pythonName, args, detail::ExportDoc<T10>::exec(help)); \
        F10::def(pythonName, args, detail::ExportDoc<T11>::exec(help)); \
        F11::def(pythonName, args, detail::ExportDoc<T12>::exec(help)); \
        F12::def(pythonName, args, detail::ExportDoc<   >::exec(help)); \
    } \
};

struct PythonMultidefFunctor {};

template <class T1,
          class T2 = void,
          class T3 = void,
          class T4 = void,
          class T5 = void,
          class T6 = void,
          class T7 = void,
          class T8 = void,
          class T9 = void,
          class T10 = void,
          class T11 = void,
          class T12 = void>
struct ArgumentMismatchMessage
{
    static std::string message()
    {
        std::string res(
            "No C++ overload matches the arguments. This can have three reasons:\n\n"
            " * The array arguments may have an unsupported element type. You may need\n"
            "   to convert your array(s) to another element type using 'array.astype(...)'.\n"
            "   The function currently supports the following types:\n\n     ");
        res += vigra::detail::TypeName<T1>::sized_name();

        if(vigra::detail::TypeName<T2>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T2>::sized_name();
        if(vigra::detail::TypeName<T3>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T3>::sized_name();
        if(vigra::detail::TypeName<T4>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T4>::sized_name();
        if(vigra::detail::TypeName<T5>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T5>::sized_name();
        if(vigra::detail::TypeName<T6>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T6>::sized_name();
        if(vigra::detail::TypeName<T7>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T7>::sized_name();
        if(vigra::detail::TypeName<T8>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T8>::sized_name();
        if(vigra::detail::TypeName<T9>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T9>::sized_name();
        if(vigra::detail::TypeName<T10>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T10>::sized_name();
        if(vigra::detail::TypeName<T11>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T11>::sized_name();
        if(vigra::detail::TypeName<T12>::sized_name() != "void")
            res += ", " + vigra::detail::TypeName<T12>::sized_name();

        res +=
            "\n\n"
            " * The dimension of your array(s) is currently unsupported (consult the\n"
            "   function's documentation for information about supported dimensions).\n\n"
            " * You provided an unrecognized argument, or an argument with incorrect type\n"
            "   (consult the documentation for valid function signatures).\n\n"
            "Additional overloads can easily be added in the vigranumpy C++ sources.\n"
            "Please submit an issue at http://github.com/ukoethe/vigra/ to let us know\n"
            "what you need (or a pull request if you solved it on your own :-).\n\n";

        return res;
    }

    static void def(const char * pythonName)
    {
        docstring_options doc(false, false, false);
        std::string msg    = message(),
                    module = extract<std::string>(scope().attr("__name__"))() + ".";
        msg += "Type 'help(" + module + pythonName + ")' to get full documentation.\n";
        boost::python::def(pythonName,
            raw_function([msg](tuple, dict) -> object {
                throw std::invalid_argument(msg);
                return object();
            }, 0));
    }
};

// in the sequel, the doc string is only registered with the last
// overload, so that it shows up only once
template <class Functor>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
multidef(char const* python_name, Functor const & f)
{
    f.def(python_name);
}

template <class Functor, class Args>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
multidef(char const* python_name, Functor const & f, Args const& args)
{
    f.def(python_name, args);
}

template <class Functor>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
multidef(char const* python_name, Functor const & f, const char * help)
{
    f.def(python_name, help);
}

template <class Functor, class Args>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
multidef(char const* python_name, Functor const & f, Args const& args, const char * help)
{
    f.def(python_name, args, help);
}

// overload def() such that it advises to use multidef() instead
template <class Functor>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
def(char const* python_name, Functor const & f)
{
    static_assert(!std::is_base_of<PythonMultidefFunctor, Functor>::value, 
                  "def(): use multidef() to export multiple overloads.");
}

template <class Functor, class Args>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
def(char const* python_name, Functor const & f, Args const& args)
{
    static_assert(!std::is_base_of<PythonMultidefFunctor, Functor>::value,
                  "def(): use multidef() to export multiple overloads.");
}

template <class Functor>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
def(char const* python_name, Functor const & f, const char * help)
{
    static_assert(!std::is_base_of<PythonMultidefFunctor, Functor>::value,
                  "def(): use multidef() to export multiple overloads.");
}

template <class Functor, class Args>
inline typename std::enable_if<std::is_base_of<PythonMultidefFunctor, Functor>::value,
                               void>::type
def(char const* python_name, Functor const & f, Args const& args, const char * help)
{
    static_assert(!std::is_base_of<PythonMultidefFunctor, Functor>::value,
                  "def(): use multidef() to export multiple overloads.");
}

}} // namespace boost::python

#endif // VIGRA_NUMPY_ARRAY_CONVERTERS_HXX