This file is indexed.

/usr/include/CCfits/FITSUtil.h is in libccfits-dev 2.5+dfsg-1+b1.

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
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
//	Astrophysics Science Division,
//	NASA/ Goddard Space Flight Center
//	HEASARC
//	http://heasarc.gsfc.nasa.gov
//	e-mail: ccfits@legacy.gsfc.nasa.gov
//
//	Original author: Ben Dorman

#ifndef FITSUTIL_H
#define FITSUTIL_H 1
#include "CCfits.h"

// functional
#include <functional>
// complex
#include <complex>
// valarray
#include <valarray>
// vector
#include <vector>
// string
#include <string>
// FitsError
#include "FitsError.h"
#include <typeinfo>


namespace CCfits {

  namespace FITSUtil {

/*! \namespace FITSUtil

\brief FITSUtil is a namespace containing functions used internally by CCfits, but
which might be of use for other applications. 

*/



/*! \class  MatchName

    \brief  predicate for classes that have a name attribute; match input string with instance name.

    Usage: MatchName<NamedClass> Ex;

    list<NamedClass> ListObject;

    //
    ...
    ...
    //

    find_if(ListObject.begin(),ListObject().end(),bind2nd(Ex,"needle"));


    Since most of the classes within CCfits are not implemented with lists, these
    functions are now of little direct use.

*/



/*! \class  MatchPtrName

    \brief  as for MatchName, only with the input class a pointer.


*/

/*! \class  MatchNum

    \brief  predicate for classes that have an index attribute; match input index with instance value.

    Usage: MatchName<IndexedClass> Ex;

    list<NamedClass> ListObject;

    //
    ...
    ...
    //

    find_if(ListObject.begin(),ListObject().end(),bind2nd(Ex,5));


    Since most of the classes within CCfits are implemented with std::maps
	 rather than lists, these functions are now of little direct use.
*/

/*! \class  MatchPtrNum
    \brief  as for MatchNum, only with the input class a pointer.
*/

/*! \class  MatchType

    \brief  function object that returns the FITS ValueType corresponding to an input intrinsic type

    This is particularly useful inside templated class instances where calls to cfitsio
    need to supply a value type. With this function one can extract the value type from
    the class type.

    <I>
    usage:

    MatchType<T> type;

    ValueType dataType = type();
    </I>

    Uses run-time type information (RTTI) methods.

*/

/*! \class  UnrecognizedType
    @ingroup FITSexcept
    @brief  exception thrown by MatchType if it encounters data type incompatible with cfitsio.

*/



/*! \class  auto_array_ptr

   \brief A class that mimics the std:: library auto_ptr class, but works
   with arrays.

   This code was written by Jack Reeves and first appeared C++ Report, March 1996
   edition. Although some authors think one shouldn't need such a contrivance, there
   seems to be a need for it when wrapping C code.

   Usage: replace

   float* <i>f</i> = new float[200];

   with

   FITSUtil::auto_array_ptr<float> <i>f(new float[200])</i>;

   Then the memory will be managed correctly in the presence of exceptions, and
   delete will be called automatically for <i>f</i> when leaving scope.

*/   

/*! \fn          explicit auto_array_ptr<X>::auto_array_ptr (X* p = 0) throw ();

        \brief constructor. allows creation of pointer to null, can be modified by reset()
*/

/*! \fn          explicit auto_array_ptr<X>::auto_array_ptr (auto_array_ptr<X>& right) throw ();
        \brief copy constructor
*/

/*!\fn          auto_array_ptr<X>::~auto_array_ptr();
        \brief destructor.
*/


/*!\fn            void auto_array_ptr<X>::operator = (auto_array_ptr<X>& right);
                \brief assignment operator: transfer of ownership semantics

*/



/*!\fn            X& auto_array_ptr<X>::operator * () throw ();
                \brief deference operator


*/

/*!\fn            X& auto_array_ptr<X>::operator [] (size_t i) throw ();
                \brief return a reference to the ith element of the array
*/

/*!\fn            X auto_array_ptr<X>::operator [] (size_t i) const throw ();
                \brief return a copy of the ith element of the array

*/

/*!\fn            X* auto_array_ptr<X>::get () const;
        \brief return a token for the underlying content of *this


*/

/*!\fn            X* auto_array_ptr<X>::release () throw ();

        \brief return underlying content of  *this, transferring memory ownership


*/

/*!\fn            X* auto_array_ptr<X>::reset (X* p) throw ();

        \brief change the content of the  auto_array_ptr to p

*/

/*!\fn            static void auto_array_ptr<X>::remove (X*& x) throw ();

        \brief utility function to delete the memory owned by x and set it to null.

*/

/*! \fn  char** CharArray(const std::vector<string>& inArray)

    \brief  function object that returns a C-array of strings from a 
    std::vector< std::vector<std::string> > object, such as used in a string valued Table column.

    This exists because the return type for a specialization (T**) is incompatible
    with typenames T other than string, which return a T*.
*/                        

/*! \class CVarray

        \brief Function object class for returning C arrays from standard library objects used
        in the FITS library implementation. 

        There are 3 versions which convert std::vector<T>, std::valarray<T>, 
        and std::vector<std::valarray<T> > objects to pointers to T, called
        CVarray, CAarray, and CVAarray.

        An alternative function, CharArray, is provided to deal with the special case of
        vector string arrays.

*/

/*! \fn  T* CVarray<T>::operator () (const std::vector<T>& inArray);

                \brief operator returning C array for use with scalar column data.
*/

/*! \class CAarray
        \brief  function object returning C array from a valarray. see CVarray for
        details                            
*/




/*! \fn  T* CAarray<T>::operator () (const std::valarray<T>& inArray);

                \brief operator returning C array for use with image data.

*/  

/*! \class CVAarray
        \brief  function object returning C array from a vector of valarrays. see CVarray for
        details                            
*/                                

/*! \fn  T* CVAarray<T>::operator () (const std::vector< std::valarray<T> >& inArray);

                \brief operator returning C array for use with vector column data.

*/


/*! \fn template <typename S, typename T> void fill(std::vector< S > &outArray, const std::vector< T > &inArray, size_t first, size_t last);

  \brief Convert input vector of type T to output vector of type S.

   The functions FITSUtil::fill do conversions between CCfits' internal representation
and user's input types. They encapsulate the task of
memory allocation also, facilitating support of implicit
conversions between the users data type and representation and what is
required by the CCfits implementation. For example a user can create a
std::vector<int> for storage in a single row of a Binary Table column,
of type long.  The internal representation is a std::valarray<long>
object.

\param outArray  output data
\param inArray  input data
\param first    first element of inArray to be written to outArray
\param last     last element of inArray to be written to outArray

*/ 

#ifdef _MSC_VER
#include "MSconfig.h" // for truncation double to float warning
#endif

     template <typename T>
    void swap(T& left,T& right);

    template <typename T>
    void swap(std::vector<T>& left, std::vector<T>& right);

    string lowerCase(const string& inputString);

    string upperCase(const string& inputString);

  // Check if a file name includes an image compression specifier,
  // and return its location if it exists.
    string::size_type checkForCompressString(const string& fileName);

  struct InvalidConversion : public FitsException
  {
		InvalidConversion(const string& diag, bool silent=false);

  };

  struct MatchStem : public std::binary_function<string,string,bool>
  {
          bool operator()(const string& left, const string& right) const;
  };

  static const  double d1(0);
  static const  float  f1(0);
  static const  std::complex<float> c1(0.);
  static const  std::complex<double> d2(0.);
  static const  string s1("");
  static const  int    i1(0);
  static const  unsigned int  u1(0);        
  static const  long l1(0);
  static const  unsigned long ul1(0);
  static const  LONGLONG ll1(0);
  static const  short s2(0);
  static const  unsigned short us1(0); 
  static const  bool b1(false);
  static const  unsigned char b2(0);  

  char** CharArray(const std::vector<string>& inArray);

  string FITSType2String( int typeInt );


  template <typename S, typename T> 
  void fill(std::vector<S>& outArray, const std::vector<T>& inArray,size_t first, size_t last);

  template <typename S, typename T> 
  void fill(std::valarray<S>& outArray, const std::valarray<T>& inArray);

  template <typename S, typename T> 
  void fill(std::valarray<S>& outArray, const std::vector<T>& inArray,size_t first, size_t last);


  template <typename S, typename T> 
  void fill(std::vector<S>& outArray, const std::valarray<T>& inArray);

  // VF<-AF
   void fill(std::vector<std::complex<float> >& outArray, 
                  const std::valarray<std::complex<float> >& inArray);

  // VF<-AD
  void fill(std::vector<std::complex<float> >& outArray, 
                  const std::valarray<std::complex<double> >& inArray);

  // VD<-AD
  void fill(std::vector<std::complex<double> >& outArray, 
                  const std::valarray<std::complex<double> >& inArray);


  // VD<-AF
  void fill(std::vector<std::complex<double> >& outArray, 
                  const std::valarray<std::complex<float> >& inArray);

  template <typename T>
  void fill(std::vector<string>& outArray, const std::vector<T>& inArray, size_t first, size_t last);

  template <typename T>
  void fill(std::vector<T>& outArray, const std::vector<string>& inArray, size_t first, size_t last);

  template <typename S> 
  void fill(std::valarray<S>& outArray, const std::vector<string>& inArray,size_t first, size_t last);

//  template <typename S, typename T>
//  void fill(std::valarray<std::complex<S> >& outArray, const std::valarray<std::complex<T> >& inArray);            
  // seems no other way of doing this.

  // VF<-VF
#ifdef TEMPLATE_AMBIG_DEFECT
  void fillMSvfvf(std::vector<std::complex<float> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#endif

  void fill(std::vector<std::complex<float> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);

  // VF<-VD
#ifdef TEMPLATE_AMBIG_DEFECT
    void fillMSvfvd(std::vector<std::complex<float> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);
#endif

   void fill(std::vector<std::complex<float> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);

   // VD<-VD
#ifdef TEMPLATE_AMBIG_DEFECT
 void fillMSvdvd(std::vector<std::complex<double> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);
#endif

   void fill(std::vector<std::complex<double> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);

#ifdef TEMPLATE_AMBIG_DEFECT
  void fillMSvdvf(std::vector<std::complex<double> >& outArray, 
				const std::vector<std::complex<float> >& inArray, 
                        size_t first, size_t last);
#else
  void fill(std::vector<std::complex<double> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#endif

  // AF<-VD
  void fill(std::valarray<std::complex<float> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);

  // AF<-VF
#ifdef TEMPLATE_AMBIG_DEFECT
 void fillMSafvf(std::valarray<std::complex<float> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#else
 void fill(std::valarray<std::complex<float> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#endif

 // AD<-VF
#ifdef TEMPLATE_AMBIG_DEFECT
  void fillMSadvf(std::valarray<std::complex<double> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#else
  void fill(std::valarray<std::complex<double> >& outArray, 
                  const std::vector<std::complex<float> >& inArray, size_t first, size_t last);
#endif

  // AD<-VD
#ifdef TEMPLATE_AMBIG_DEFECT
  void fillMSadvd(std::valarray<std::complex<double> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);
#else
  void fill(std::valarray<std::complex<double> >& outArray, 
                  const std::vector<std::complex<double> >& inArray, size_t first, size_t last);
#endif

  // AF<-AF
  void fill(std::valarray<std::complex<float> >& outArray,  
                  const std::valarray<std::complex<float> >& inArray);
  // AD<-AD
  void fill(std::valarray<std::complex<double> >& outArray,  
                  const std::valarray<std::complex<double> >& inArray);
  // AF<-AD
  void fill(std::valarray<std::complex<float> >& outArray, 
                  const std::valarray<std::complex<double> >& inArray);
  // AD<-AF
  void fill(std::valarray<std::complex<double> >& outArray,  
                  const std::valarray<std::complex<float> >& inArray);

#if TEMPLATE_AMBIG_DEFECT || TEMPLATE_AMBIG7_DEFECT
  void fillMSvsvs(std::vector<string>& outArray, const std::vector<string>& inArray, size_t first, size_t last);
#endif


  void fill(std::vector<string>& outArray, const std::vector<string>& inArray, size_t first, size_t last);

  template <typename S, typename T>
  string errorMessage(const S& out, const T& in);



    template <class T>
    struct MatchPtrName : public std::binary_function<T,std::string,bool>  //## Inherits: <unnamed>%39491BC9025D
    {
          //	Parameterized Class MatchPtrName
          bool operator () (const T& left, const string& right) const;

      public:
      protected:
      private:
      private: //## implementation
    };



    template <class T>
    struct MatchName : public std::binary_function<T,std::string,bool>  //## Inherits: <unnamed>%39491BC50121
    {
          bool operator () (const T& left, const string& right) const;

      public:
      protected:
      private:
      private: //## implementation
    };



    template <class T>
    struct MatchNum : public std::binary_function<T,int,bool>  //## Inherits: <unnamed>%39491BCE01C0
    {
          bool operator () (const T& left, const int& right) const;

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct MatchType 
    {
          ValueType operator () ();

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct CVarray 
    {
          T* operator () (const std::vector<T>& inArray);

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct FitsNullValue 
    {
          T operator () ();

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct MatchImageType 
    {
          ImageType operator () ();

      public:
      protected:
      private:
      private: //## implementation
    };



    template <class T>
    struct MatchPtrNum : public std::binary_function<T,int,bool>  //## Inherits: <unnamed>%39491BD3034B
    {
          bool operator () (const T& left, const int& right) const;

      public:
      protected:
      private:
      private: //## implementation
    };
    //	auto_ptr analogue for arrays.



    template <typename X>
    class auto_array_ptr 
    {
      public:
          explicit auto_array_ptr (X* p = 0) throw ();
          explicit auto_array_ptr (auto_array_ptr<X>& right) throw ();
          ~auto_array_ptr();

          void operator = (auto_array_ptr<X>& right);
          X& operator * () throw ();
          X& operator [] (size_t i) throw ();
          X operator [] (size_t i) const throw ();
          X* get () const;
          X* release () throw ();
          X* reset (X* p) throw ();
          static void remove (X*& x);

      protected:
      private:
      private: //## implementation
        // Data Members for Class Attributes
          X* m_p;

    };



    template <typename T>
    struct ComparePtrIndex : public std::binary_function<T,T,bool>  //## Inherits: <unnamed>%3B24DB930299
    {
          bool operator () (const T* left, const T* right);

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct CAarray 
    {
          T* operator () (const std::valarray<T>& inArray);

      public:
      protected:
      private:
      private: //## implementation
    };



    template <typename T>
    struct CVAarray 
    {
          T* operator () (const std::vector< std::valarray<T> >& inArray);

      public:
      protected:
      private:
      private: //## implementation
    };



    class UnrecognizedType : public FitsException  //## Inherits: <unnamed>%3CE143AB00C6
    {
      public:
          UnrecognizedType (string diag, bool silent = true);

      protected:
      private:
      private: //## implementation
    };

    // Parameterized Class CCfits::FITSUtil::MatchPtrName 

    template <class T>
    inline bool MatchPtrName<T>::operator () (const T& left, const string& right) const
    {
       return left->name() == right;
    }

    // Parameterized Class CCfits::FITSUtil::MatchName 

    template <class T>
    inline bool MatchName<T>::operator () (const T& left, const string& right) const
    {
       return left.name() == right;
    }

    // Parameterized Class CCfits::FITSUtil::MatchNum 

    template <class T>
    inline bool MatchNum<T>::operator () (const T& left, const int& right) const
    {
    return left.index() == right;
    }

    // Parameterized Class CCfits::FITSUtil::MatchType 

    // Parameterized Class CCfits::FITSUtil::CVarray 

    template <typename T>
    inline T* CVarray<T>::operator () (const std::vector<T>& inArray)
    {

      // convert std containers used commonly in FITS to C arrays in an exception
      // safe manner that is also clear about resource ownership.      
      auto_array_ptr<T> pC(new T[inArray.size()]);
      T* c = pC.get();
      std::copy(inArray.begin(),inArray.end(),&c[0]);
      return pC.release();
    }

    // Parameterized Class CCfits::FITSUtil::FitsNullValue 

    template <typename T>
    inline T FitsNullValue<T>::operator () ()
    {
       // This works for int types.  Float, complex, and string types 
       //   are handled below with specialized templates.
       return 0;
    }

    // Parameterized Class CCfits::FITSUtil::MatchImageType 

    // Parameterized Class CCfits::FITSUtil::MatchPtrNum 

    template <class T>
    inline bool MatchPtrNum<T>::operator () (const T& left, const int& right) const
    {
    return left->index() == right;
    }

    // Parameterized Class CCfits::FITSUtil::auto_array_ptr 

    // Parameterized Class CCfits::FITSUtil::ComparePtrIndex 

    // Parameterized Class CCfits::FITSUtil::CAarray 

    // Parameterized Class CCfits::FITSUtil::CVAarray 

    // Class CCfits::FITSUtil::UnrecognizedType 

    // Parameterized Class CCfits::FITSUtil::MatchPtrName 

    // Parameterized Class CCfits::FITSUtil::MatchName 

    // Parameterized Class CCfits::FITSUtil::MatchNum 

    // Parameterized Class CCfits::FITSUtil::MatchType 

    template <typename T>
    ValueType MatchType<T>::operator () ()
    {

    if ( typeid(T) == typeid(d1) ) return Tdouble;
    if ( typeid(T) == typeid(f1) ) return Tfloat;
    if ( typeid(T) == typeid(c1) ) return Tcomplex;
    if ( typeid(T) == typeid(d2) ) return Tdblcomplex;
    if ( typeid(T) == typeid(s1) ) return Tstring;
    if ( typeid(T) == typeid(i1) ) return Tint;
    if ( typeid(T) == typeid(u1) ) return Tuint;
    if ( typeid(T) == typeid(s2) ) return Tshort;
    if ( typeid(T) == typeid(us1) ) return Tushort;
    if ( typeid(T) == typeid(b1) ) return Tlogical;
    if ( typeid(T) == typeid(b2) ) return Tbyte;
    if ( typeid(T) == typeid(l1) ) return Tlong;
    if ( typeid(T) == typeid(ul1) ) return Tulong;
    // Carefull, on some compilers LONGLONG == long,
    // so this should go after test for long.
    if ( typeid(T) == typeid(ll1) ) return Tlonglong;
    throw UnrecognizedType("Invalid data type for FITS Data I/O\n");    
    }

    // Parameterized Class CCfits::FITSUtil::CVarray 

    // Parameterized Class CCfits::FITSUtil::MatchImageType 

    template <typename T>
    ImageType MatchImageType<T>::operator () ()
    {
    if ( typeid(T) == typeid(b2) ) return Ibyte;    
    if ( typeid(T) == typeid(s2) ) return Ishort;
    if ( typeid(T) == typeid(l1) ) return Ilong;
    if ( typeid(T) == typeid(f1) ) return Ifloat;
    if ( typeid(T) == typeid(d1) ) return Idouble;
    if ( typeid(T) == typeid(us1) ) return Iushort;
    if ( typeid(T) == typeid(ul1) ) return Iulong;
    if ( typeid(T) == typeid(ll1) ) return Ilonglong;
    MatchType<T> errType;
    string diag ("Image: ");
    diag += FITSType2String(errType());
    throw UnrecognizedType(diag);        
    }

    // Parameterized Class CCfits::FITSUtil::MatchPtrNum 

    // Parameterized Class CCfits::FITSUtil::auto_array_ptr 

    template <typename X>
    auto_array_ptr<X>::auto_array_ptr (X* p) throw ()
          : m_p(p)
    {
    }

    template <typename X>
    auto_array_ptr<X>::auto_array_ptr (auto_array_ptr<X>& right) throw ()
          : m_p(right.release())
    {
    }


    template <typename X>
    auto_array_ptr<X>::~auto_array_ptr()
    {
      delete [] m_p;
    }


    template <typename X>
    void auto_array_ptr<X>::operator = (auto_array_ptr<X>& right)
    {
      if (this != &right)
      {
                remove(m_p);
                m_p = right.release();       
      }
    }

    template <typename X>
    X& auto_array_ptr<X>::operator * () throw ()
    {
      return *m_p;
    }

    template <typename X>
    X& auto_array_ptr<X>::operator [] (size_t i) throw ()
    {
      return m_p[i];
    }

    template <typename X>
    X auto_array_ptr<X>::operator [] (size_t i) const throw ()
    {
      return m_p[i];
    }

    template <typename X>
    X* auto_array_ptr<X>::get () const
    {
      return m_p;
    }

    template <typename X>
    X* auto_array_ptr<X>::release () throw ()
    {
      return reset(0);
    }

    template <typename X>
    X* auto_array_ptr<X>::reset (X* p) throw ()
    {
      // set the auto_ptr to manage p and return the old pointer it was managing.
      X* __tmp = m_p; 
      m_p = p;
      return __tmp;
    }

    template <typename X>
    void auto_array_ptr<X>::remove (X*& x)
    {
      X* __tmp(x);
      x = 0;
      delete [] __tmp;
    }

    // Parameterized Class CCfits::FITSUtil::ComparePtrIndex 

    template <typename T>
    bool ComparePtrIndex<T>::operator () (const T* left, const T* right)
    {
      return (left->index() < right->index());
    }

    // Parameterized Class CCfits::FITSUtil::CAarray 

    template <typename T>
    T* CAarray<T>::operator () (const std::valarray<T>& inArray)
    {
      size_t n(inArray.size());
      auto_array_ptr<T> pC(new T[n]);
      T* c= pC.get();
      for (size_t j = 0; j < n; ++j) c[j] = inArray[j];
      return pC.release();      
    }

    // Parameterized Class CCfits::FITSUtil::CVAarray 

    template <typename T>
    T* CVAarray<T>::operator () (const std::vector< std::valarray<T> >& inArray)
    {
      size_t  sz(0);
      size_t  n(inArray.size());

      std::vector<size_t> nr(n);

      size_t i = 0; // for MS VC++ bug
      for ( i = 0; i < n; ++i)
      {
         nr[i] = inArray[i].size();
	 sz += nr[i];

      }
      auto_array_ptr<T> pC(new T[sz]);
      T* c = pC.get();

      size_t k(0);
      for ( i = 0; i < n; ++i)
      {
         size_t& m = nr[i];
         const std::valarray<T>& current = inArray[i];
	 for (size_t j=0; j < m ; ++j) c[k++] = current[j];
      }

      return pC.release();      
    }

  } // namespace FITSUtil
} // namespace CCfits

namespace CCfits
{

   namespace FITSUtil
   {                

      template <typename T>
      void swap(T& left, T& right)
      {
              T temp(left);
              left = right;
              right = temp;                
      }

      template <typename T>
      void swap(std::vector<T>& left, std::vector<T>& right)
      {
              left.swap(right);        
      }

      template <>
      inline string FitsNullValue<string>::operator () ()
      {
	 return string("");
      }
      
      template <>
      inline float FitsNullValue<float>::operator () ()
      {
         return FLOATNULLVALUE;
      }

      template <>
      inline double FitsNullValue<double>::operator () ()
      {
         return DOUBLENULLVALUE;
      }
      
      template <>
      inline std::complex<float> FitsNullValue<std::complex<float> >::operator () ()
      {
         return std::complex<float>(FLOATNULLVALUE);
      }

      template <>
      inline std::complex<double> FitsNullValue<std::complex<double> >::operator () ()
      {
         return std::complex<double>(DOUBLENULLVALUE);
      }
      
   } // end namespace FITSUtil
} // end namespace CCfits



#endif