File: concept_checking.h

package info (click to toggle)
openms 2.6.0%2Bcleaned1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 783,124 kB
  • sloc: cpp: 526,887; xml: 142,287; ansic: 54,252; python: 11,640; php: 2,454; sh: 1,137; ruby: 529; yacc: 403; perl: 85; lex: 74; makefile: 60
file content (1007 lines) | stat: -rw-r--r-- 39,297 bytes parent folder | download | duplicates (6)
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
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2013, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Knut Reinert or the FU Berlin nor the names of
//       its contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
// ==========================================================================
// A minimal subset of the Boost Concept Checking Library.  A lot of the code
// in the BCCL deals with support of non-conforming compilers and we cut this
// away.  The code here has been adjusted to work with the compilers supported
// by SeqAn and be as simple as possible while still creating useful compiler
// errors.
// ==========================================================================

// SEQAN_NO_GENERATED_FORWARDS

#ifndef CORE_INCLUDE_SEQAN_BASIC_CONCEPT_CHECKING_H_
#define CORE_INCLUDE_SEQAN_BASIC_CONCEPT_CHECKING_H_

namespace seqan {

// ---------------------------------------------------------------------------
// ==> boost/static_assert.hpp <==
// ---------------------------------------------------------------------------

//  (C) Copyright John Maddock 2000.
//  Use, modification and distribution are subject to the 
//  Boost Software License, Version 1.0. (See accompanying file 
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/static_assert for documentation.

#ifdef SEQAN_CXX11_STANDARD
#  define SEQAN_STATIC_ASSERT_MSG( B, Msg ) static_assert(B, Msg)
#else
#  define SEQAN_STATIC_ASSERT_MSG( B, Msg ) SEQAN_STATIC_ASSERT( B )
#endif

//
// If the compiler issues warnings about old C style casts,
// then enable this:
//
//#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)))
//#  define BOOST_STATIC_ASSERT_BOOL_CAST( x ) ((x) == 0 ? false : true)
//#else
#  define SEQAN_STATIC_ASSERT_BOOL_CAST(x) (bool)(x)
//#endif

//
// If the compiler warns about unused typedefs then enable this:
//
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
#  define SEQAN_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))
#else
#  define SEQAN_STATIC_ASSERT_UNUSED_ATTRIBUTE
#endif

#ifdef SEQAN_CXX11_STANDARD
#  define SEQAN_STATIC_ASSERT( B ) static_assert(B, #B)
#else

// HP aCC cannot deal with missing names for template value parameters
template <bool x> struct STATIC_ASSERTION_FAILURE;

template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };

// HP aCC cannot deal with missing names for template value parameters
template<int x> struct static_assert_test{};

//
// Implicit instantiation requires that all member declarations be
// instantiated, but that the definitions are *not* instantiated.
//
// It's not particularly clear how this applies to enum's or typedefs;
// both are described as declarations [7.1.3] and [7.2] in the standard,
// however some compilers use "delayed evaluation" of one or more of
// these when implicitly instantiating templates.  We use typedef declarations
// by default, but try defining SEQAN_USE_ENUM_STATIC_ASSERT if the enum
// version gets better results from your compiler...
//
// Implementation:
// Both of these versions rely on sizeof(incomplete_type) generating an error
// message containing the name of the incomplete type.  We use
// "STATIC_ASSERTION_FAILURE" as the type name here to generate
// an eye catching error message.  The result of the sizeof expression is either
// used as an enum initialiser, or as a template argument depending which version
// is in use...
// Note that the argument to the assert is explicitly cast to bool using old-
// style casts: too many compilers currently have problems with static_cast
// when used inside integral constant expressions.
//
//#if !defined(SEQAN_BUGGY_INTEGRAL_CONSTANT_EXPRESSIONS)
/*
#if defined(SEQAN_MSVC) && (SEQAN_MSVC < 1300)
// __LINE__ macro broken when -ZI is used see Q199057
// fortunately MSVC ignores duplicate typedef's.
#define SEQAN_STATIC_ASSERT( B ) \
   typedef static_assert_test<\
      sizeof(STATIC_ASSERTION_FAILURE< (bool)( B ) >)\
      > seqan_static_assert_typedef_
#elif defined(SEQAN_MSVC)
*/
#if defined(PLATFORM_WINDOWS_VS)
#define SEQAN_STATIC_ASSERT( B ) \
   typedef static_assert_test<\
      sizeof(STATIC_ASSERTION_FAILURE< SEQAN_STATIC_ASSERT_BOOL_CAST ( B ) >)>\
         SEQAN_JOIN(seqan_static_assert_typedef_, __COUNTER__)
/*
#elif defined(SEQAN_INTEL_CXX_VERSION) || defined(SEQAN_SA_GCC_WORKAROUND)
// agurt 15/sep/02: a special care is needed to force Intel C++ issue an error 
// instead of warning in case of failure
# define SEQAN_STATIC_ASSERT( B ) \
    typedef char SEQAN_JOIN(seqan_static_assert_typedef_, __LINE__) \
        [ STATIC_ASSERTION_FAILURE< SEQAN_STATIC_ASSERT_BOOL_CAST( B ) >::value ]
#elif defined(__sgi)
// special version for SGI MIPSpro compiler
#define SEQAN_STATIC_ASSERT( B ) \
   SEQAN_STATIC_CONSTANT(bool, \
     SEQAN_JOIN(boost_static_assert_test_, __LINE__) = ( B )); \
   typedef static_assert_test<\
     sizeof(STATIC_ASSERTION_FAILURE< \
       SEQAN_JOIN(boost_static_assert_test_, __LINE__) >)>\
         SEQAN_JOIN(seqan_static_assert_typedef_, __LINE__)
#elif SEQAN_WORKAROUND(__MWERKS__, <= 0x3003)
// special version for CodeWarrior <= 8.x
#define SEQAN_STATIC_ASSERT( B ) \
   SEQAN_STATIC_CONSTANT(int, \
     SEQAN_JOIN(boost_static_assert_test_, __LINE__) = \
       sizeof(STATIC_ASSERTION_FAILURE< SEQAN_STATIC_ASSERT_BOOL_CAST( B ) >) )
*/
#else
// generic version
#define SEQAN_STATIC_ASSERT( B ) \
   typedef static_assert_test<\
      sizeof(STATIC_ASSERTION_FAILURE< SEQAN_STATIC_ASSERT_BOOL_CAST( B ) >)>\
         SEQAN_JOIN(seqan_static_assert_typedef_, __LINE__) SEQAN_STATIC_ASSERT_UNUSED_ATTRIBUTE
#endif
/*
#else
// alternative enum based implementation:
#define SEQAN_STATIC_ASSERT( B ) \
   enum { SEQAN_JOIN(boost_static_assert_enum_, __LINE__) \
      = sizeof(STATIC_ASSERTION_FAILURE< (bool)( B ) >) }
#endif
*/
#endif

// ---------------------------------------------------------------------------
// ==> boost/parameter/aux_/paranthesized_type.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

template <class UnaryFunctionPointer>
struct unaryfunptr_arg_type;

template <class Arg>
struct unaryfunptr_arg_type<void(*)(Arg)>
{
    typedef Arg type; 
};

template <>
struct unaryfunptr_arg_type<void(*)(void)>
{
    typedef void type;
};

// ---------------------------------------------------------------------------
// ==> boost/concept_check/general.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

namespace concept_checking
{
template <void(*)()> struct instantiate {};
}

template <class ModelFn> struct concept_check_;

template <class Model>
void concept_check_failed()
{
    ((Model*)0)->~Model();
}

template <class Model>
struct concept_check
{
    concept_checking::instantiate<concept_check_failed<Model> > x;
    enum { instantiate = 1 };
};

template <class Model>
struct concept_check_<void(*)(Model)>
        : concept_check<Model>
{};

#  define SEQAN_CONCEPT_ASSERT_FN( ModelFnPtr )             \
    typedef ::seqan::detail::instantiate<          \
    &::seqan::requirement_<ModelFnPtr>::failed>    \
      SEQAN_PP_CAT(seqan_concept_check,__LINE__) SEQAN_STATIC_ASSERT_UNUSED_ATTRIBUTE

// ---------------------------------------------------------------------------
// ==> boost/concept/assert.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

/*!
 * @macro SEQAN_CONCEPT_ASSERT
 * @brief Perform a concept check.
 * @headerfile <seqan/basic.h>
 * 
 * @signature SEQAN_CONCEPT_ASSERT((concept))
 * 
 * @param concept Concept specialized with a the type that should be checked.
 * 
 * @section Remarks
 * 
 * This macro is a compile-time assertion and requires the concept specialized
 * with the tested types to compile. The check neither consumes memory nor
 * running time. The macro can be used at the beginning of a function or within
 * a struct/class definition. The checked concepts should be as restrictive and
 * generic as possible to on the one hand cover all used functionality and on
 * the other hand not limit the applicability of a function/class.
 * 
 * @section Examples
 * 
 * @code{.cpp}
 * typedef typename Value<TContainer>::Type                TValue;
 * typedef typename Position<TContainer>::Type             TPosition;
 * typedef typename Difference<TContainer>::Type           TDifference;
 *  
 * SEQAN_CONCEPT_ASSERT((AlphabetConcept<TValue>));
 * SEQAN_CONCEPT_ASSERT((SignedIntegerConcept<TDifference>));
 * SEQAN_CONCEPT_ASSERT((UnsignedIntegerConcept<TSize>));
 * @endcode
 * @see Is
 */

/**
.Macro.SEQAN_CONCEPT_ASSERT
..cat:Concepts
..summary:Perform a concept check.
..signature:SEQAN_CONCEPT_ASSERT((concept))
..param.concept:Concept specialized with a the type that should be checked.
..remarks:This macro is a compile-time assertion and requires the concept specialized with the tested types to compile.
The check neither consumes memory nor running time.
The macro can be used at the beginning of a function or within a struct/class definition.
The checked concepts should be as restrictive and generic as possible to on the one hand 
cover all used functionality and on the other hand not limit the applicability of a function/class.
..example.code:
typedef typename Value<TContainer>::Type                TValue;
typedef typename Position<TContainer>::Type             TPosition;
typedef typename Difference<TContainer>::Type           TDifference;

SEQAN_CONCEPT_ASSERT((AlphabetConcept<TValue>));
SEQAN_CONCEPT_ASSERT((SignedIntegerConcept<TDifference>));
SEQAN_CONCEPT_ASSERT((UnsignedIntegerConcept<TSize>));
..include:seqan/basic.h
 */

// Usage, in class or function context:
//     SEQAN_CONCEPT_ASSERT((UnaryFunctionConcept<F,bool,int>));
# define SEQAN_CONCEPT_ASSERT(ModelInParens) \
    SEQAN_CONCEPT_ASSERT_FN(void(*)ModelInParens)

// usage.hpp

template <class Model>
struct usage_requirements
{
    ~usage_requirements() { ((Model*)0)->~Model(); }
};

/*!
 * @macro SEQAN_CONCEPT_USAGE
 * @headerfile <seqan/basic.h>
 * @brief Defines valid expressions.
 *
 * @signature SEQAN_CONCEPT_USAGE(name)
 *
 * @param[in] name Identifier of the concept defined with @link SEQAN_CONCEPT @endlink or @link SEQAN_CONCEPT_REFINE
 *                 @endlink.
 *
 * This macro should be used to introduce a block (enclosed with curly braces) of valid expressions within a newly
 * defined concept.  Valid expressions should test for available functions, operators and the correctness of return
 * types.  Use helper functions, e.g. @link ignoreUnusedVariableWarning @endlink, @link requireBooleanExpr @endlink and
 * @link sameType @endlink.
 *
 * @section Examples
 *
 * @code{.cpp}
 * SEQAN_CONCEPT(EqualityComparable,(T))
 * {
 *     SEQAN_CONCEPT_USAGE(EqualityComparable) 
 *     {
 *         requireBooleanExpr(a == b);
 *         requireBooleanExpr(a != b);
 *     }
 * private:
 *     T a, b;
 * };
 * @endcode
 *
 * @see requireBooleanExpr
 * @see SEQAN_CONCEPT
 * @see SEQAN_CONCEPT_REFINE
 */

/**
.Macro.SEQAN_CONCEPT_USAGE
..cat:Concepts
..summary:Define valid expressions.
..signature:SEQAN_CONCEPT_USAGE(name)
..param.name:Identifier of the concept defined with @Macro.SEQAN_CONCEPT@ or @Macro.SEQAN_CONCEPT_REFINE@.
..remarks:This macro should be used to introduce a block (enclosed with curly braces) of valid expressions within
a newly defined concept.
Valid expressions should test for available functions, operators and the correctness of return types.
Use helper functions, e.g. @Function.ignoreUnusedVariableWarning@, @Function.requireBooleanExpr@ and @Function.sameType@.
..example.code:
SEQAN_CONCEPT(EqualityComparable,(T))
{
    SEQAN_CONCEPT_USAGE(EqualityComparable) 
    {
        requireBooleanExpr(a == b);
        requireBooleanExpr(a != b);
    }
private:
    T a, b;
};
..see:Function.requireBooleanExpr
..see:Macro.SEQAN_CONCEPT
..see:Macro.SEQAN_CONCEPT_REFINE
..include:seqan/basic.h
 */
#define SEQAN_CONCEPT_USAGE(model)                                      \
    SEQAN_CONCEPT_ASSERT((seqan::usage_requirements<model>));           \
    ~model()

// ---------------------------------------------------------------------------
// ==> boost/concept/detail/has_constraints.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

namespace detail {
  typedef char yes;
  typedef char (&no)[2];

  template <class Model, void (Model::*)()>
  struct wrap_constraints {};
    
  template <class Model>
  inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
  inline no has_constraints_(...);
}

// This would be called "detail::has_constraints," but it has a strong
// tendency to show up in error messages.
template <class Model>
struct not_satisfied
{
    enum {value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) };
    typedef typename Eval<value>::Type Type;
};

// ---------------------------------------------------------------------------
// ==> boost/concept_check/detail/general.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

template <class ModelFn>
struct requirement_;

namespace detail
{
  template <void(*)()> struct instantiate {};
}

template <class Model>
struct requirement
{
    static void failed() { ((Model*)0)->~Model(); }
};

struct failed {};

template <class Model>
struct requirement<failed ************ Model::************>
{
    static void failed() { ((Model*)0)->~Model(); }
};

template <class Model>
struct constraint
{
    static void failed() { ((Model*)0)->constraints(); }
};
  
template <class Model>
struct requirement_<void(*)(Model)>
        : IfC<not_satisfied<Model>::Type::VALUE, /* should be called "has_constraints", see above */
              constraint<Model>,
              requirement<failed ************ Model::************>
              >::Type
{};

#  define SEQAN_CONCEPT_ASSERT_FN( ModelFnPtr )             \
    typedef ::seqan::detail::instantiate<          \
    &::seqan::requirement_<ModelFnPtr>::failed>    \
      SEQAN_PP_CAT(seqan_concept_check,__LINE__) SEQAN_STATIC_ASSERT_UNUSED_ATTRIBUTE

// ---------------------------------------------------------------------------
// ==> boost/concept_check/detail/requires.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).

// Template for use in handwritten assertions
template <class Model, class More>
struct requires_ : More
{
    SEQAN_CONCEPT_ASSERT((Model));
};

// Template for use by macros, where models must be wrapped in parens.
// This isn't in namespace detail to keep extra cruft out of resulting
// error messages.

template <class ModelFn>
struct _requires_
{
    enum { value = 0 };
    SEQAN_CONCEPT_ASSERT_FN(ModelFn);
};

template <int check, class Result>
struct Requires_ : unaryfunptr_arg_type<Result>
{};

#  define SEQAN_CONCEPT_REQUIRES_(r,data,t) + (::seqan::_requires_<void(*)t>::value)

#if defined(NDEBUG)

# define SEQAN_CONCEPT_REQUIRES(models, result)                      \
    typename unaryfunptr_arg_type<void(*)result>::type

#else  // #if defined(NDEBUG)

# define SEQAN_CONCEPT_REQUIRES(models, result)                                        \
    typename ::seqan::Requires_<                                                       \
      (0 SEQAN_PP_SEQ_FOR_EACH(SEQAN_CONCEPT_REQUIRES_, ~, models)),                   \
      void(*)result                                                                 \
    >::type

#endif  // #if defined(NDEBUG)

// ---------------------------------------------------------------------------
// ==> boost/concept_check.hpp <==
// ---------------------------------------------------------------------------

//
// (C) Copyright Jeremy Siek 2000.
// Copyright 2002 The Trustees of Indiana University.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)    //
// Backward compatibility
//

template <class Model>
inline void functionRequires(Model* = 0)
{
    SEQAN_CONCEPT_ASSERT((Model));
}

/*!
 * @fn ignoreUnusedVariableWarning
 * @headefile <seqan/basic.h>
 * @brief Removes unused variable warning.
 *
 * @signature void ignoreUnusedVariableWarning(x);
 *
 * @param[in] x Variable that causes the unused variable warning.
 *
 * It sometimes is necessary to define variables which are not further used, e.g. to check available assignment
 * operators.  Use this functions to remove a compile warning that otherwise would be raised in this case.
 */

/**
.Function.ignoreUnusedVariableWarning
..summary:Removes unused variable warning.
..cat:Concepts
..signature:ignoreUnusedVariableWarning(x)
..param.x: Variable that causes the unused variable warning.
..remarks:It sometimes is necessary to define variables which are not further used, e.g. to check available assignment operators.
Use this functions to remove a compile warning that otherwise would be raised in this case.
..see:Macro.SEQAN_CONCEPT_USAGE
..include:seqan/basic.h
 */
template <class T> SEQAN_HOST_DEVICE inline void ignoreUnusedVariableWarning(T const&) {}

// ---------------------------------------------------------------------------
// ==> boost/concept/detail/concept_def.hpp <==
// ---------------------------------------------------------------------------

// Copyright David Abrahams 2006. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// SEQAN_CONCEPT_REFINE added by David Weese

/*!
 * @macro SEQAN_CONCEPT
 * @brief Defines a new concept.
 * @headerfile seqan/basic.h
 * 
 * @signature SEQAN_CONCEPT(name, params)
 * 
 * @param params Template paramter list in parantheses, e.g. (T) or (T1)(T2).
 *               Typically, template parameters are models, i.e. one or multiple
 *               classes that should be checked for fulfilling a concept.This is
 *               a sequence of the Boost Preprocessor Library, read <a
 *               href="http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html">more</a>.
 * @param name Concept identifier. Non-trivial concepts should have an
 *             identifier with a Concept-suffix.
 * 
 * @section Remarks
 * 
 * A concept is implemented as a template struct with name <tt>name</tt> and
 * arguments <tt>params</tt>. The concept checking should be part of the struct
 * definition. Associated types should be checked via @link SEQAN_CONCEPT_ASSERT
 * @endlink and valid expressions in a function @link SEQAN_CONCEPT_USAGE
 * @endlink, see below. Variables used in valid expressions should be (private)
 * struct members instead of local variables in member functions (read <a
 * href="http://www.boost.org/doc/libs/1_47_0/libs/concept_check/creating_concepts.htm">more</a>.
 * 
 * @section Examples
 * 
 * @code{.cpp}
 * SEQAN_CONCEPT(Assignable,(T))
 * {
 *     SEQAN_CONCEPT_USAGE(Assignable)
 *     {
 *         a = b;              // require assignment operator
 *         constConstraints(b);
 *     }
 * private:
 *     void constConstraints(const T& x)
 *     {
 *         a = x;              // const required for argument to assignment
 *         ignoreUnusedVariableWarning(x);
 *     }
 * private:
 *     T a;
 *     T b;
 * };
 *  
 * SEQAN_CONCEPT(EqualityComparable,(T))
 * {
 *     SEQAN_CONCEPT_USAGE(EqualityComparable)
 *     {
 *         requireBooleanExpr(a == b);
 *         requireBooleanExpr(a != b);
 *     }
 * private:
 *     T a, b;
 * };
 * @endcode
 *
 * @see SEQAN_CONCEPT_USAGE
 */

/**
.Macro.SEQAN_CONCEPT
..cat:Concepts
..summary:Defines a new concept.
..signature:SEQAN_CONCEPT(name, params)
..param.name:Concept identifier. Non-trivial concepts should have an identifier with a "Concept"-suffix.
..param.params:Template paramter list in parantheses, e.g. (T) or (T1)(T2).
Typically, template parameters are models, i.e. one or multiple classes that should be checked for fulfilling a concept.
...remarks:This is a sequence of the Boost Preprocessor Library, read @http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html|more@.
..remarks:A concept is implemented as a template struct with name $name$ and arguments $params$.
The concept checking should be part of the struct definition.
Associated types should be checked via @Macro.SEQAN_CONCEPT_ASSERT@ and valid expressions in a function @Macro.SEQAN_CONCEPT_USAGE@, see below.
Variables used in valid expressions should be (private) struct members instead of local variables in member functions (read @http://www.boost.org/doc/libs/1_47_0/libs/concept_check/creating_concepts.htm|more@).
..example.code:
SEQAN_CONCEPT(Assignable,(T))
{
    SEQAN_CONCEPT_USAGE(Assignable) 
    {
        a = b;              // require assignment operator
        constConstraints(b);
    }
private:
    void constConstraints(const T& x) 
    {
        a = x;              // const required for argument to assignment
        ignoreUnusedVariableWarning(x);
    }
private:
    T a;
    T b;
};

SEQAN_CONCEPT(EqualityComparable,(T))
{
    SEQAN_CONCEPT_USAGE(EqualityComparable) 
    {
        requireBooleanExpr(a == b);
        requireBooleanExpr(a != b);
    }
private:
    T a, b;
};
..include:seqan/basic.h
 */

# define SEQAN_CONCEPT(name, params)                                            \
    template < SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_typename,~,params) >       \
    struct name

/*!
 * @macro SEQAN_CONCEPT_REFINE
 * @brief Defines a new concept as a refinement of existing concepts.
 * @headerfile seqan/basic.h
 * 
 * @signature SEQAN_CONCEPT_REFINE(name, params, refinedConcepts)
 * 
 * @param params Template paramter list in parantheses, e.g. (T) or (T1)(T2).
 *               Typically, template parameters are models, i.e. one or multiple
 *               classes that should be checked for fulfilling a concept.This is
 *               a sequence of the Boost Preprocessor Library, read <a
 *               href="http://boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html">more</a>.
 * @param name Concept identifier. Non-trivial concepts should have an
 *             identifier with a Concept-suffix.
 * @param refinedConcepts Identifiers of concepts that are refined by the new
 *                        concept.Refined concepts are implicitly integrated
 *                        into the requirements of the new concept.This is a
 *                        sequence of the Boost Preprocessor Library, read
 *                        <a href="http://boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html">more</a>
 * 
 * @section Remarks
 * 
 * A concept is implemented as a template struct with name <tt>name</tt> and
 * arguments <tt>params</tt>. The struct inherits all refined concept structs.
 * The concept checking should be part of the struct definition. For more
 * information, see @link SEQAN_CONCEPT @endlink.
 * 
 * @section Examples
 * 
 * @code{.cpp}
 * SEQAN_CONCEPT_REFINE(AlphabetConcept, (TValue), (Assignable)(DefaultConstructible)(CopyConstructible))
 * {
 *     TValue val, val2;
 *  
 *     SEQAN_CONCEPT_USAGE(AlphabetConcept)
 *     {
 *         assign(val, val2);
 *     }
 * };
 * @endcode
 * @see SEQAN_CONCEPT_USAGE
 */

/**
.Macro.SEQAN_CONCEPT_REFINE
..cat:Concepts
..summary:Defines a new concept as a refinement of existing concepts.
..signature:SEQAN_CONCEPT_REFINE(name, params, refinedConcepts)
..param.name:Concept identifier. Non-trivial concepts should have an identifier with a "Concept"-suffix.
..param.params:Template paramter list in parantheses, e.g. (T) or (T1)(T2).
Typically, template parameters are models, i.e. one or multiple classes that should be checked for fulfilling a concept.
...remarks:This is a sequence of the Boost Preprocessor Library, read @http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html|more@.
..param.refinedConcepts:Identifiers of concepts that are refined by the new concept.
...remarks:Refined concepts are implicitly integrated into the requirements of the new concept.
...remarks:This is a sequence of the Boost Preprocessor Library, read @http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html|more@.
..remarks:A concept is implemented as a template struct with name $name$ and arguments $params$.
The struct inherits all refined concept structs.
The concept checking should be part of the struct definition.
For more information, see @Macro.SEQAN_CONCEPT@.
..example.code:
SEQAN_CONCEPT_REFINE(AlphabetConcept, (TValue), (Assignable)(DefaultConstructible)(CopyConstructible))
{
    TValue val, val2;

    SEQAN_CONCEPT_USAGE(AlphabetConcept)
    {
        assign(val, val2); 
    }
};
..include:seqan/basic.h
 */

# define SEQAN_CONCEPT_REFINE(name, params, refinedConcepts)                                        \
    template < SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_typename,~,params) >                           \
    struct name;                                                                                    \
                                                                                                    \
    template < SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_typename,~,params) >                           \
    struct Refines< name<SEQAN_PP_SEQ_ENUM(params)> >                                               \
    {                                                                                               \
        typedef                                                                                     \
            SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_LIST_prefix,params,refinedConcepts)               \
            SEQAN_PP_REPEAT(SEQAN_PP_SEQ_SIZE(refinedConcepts),SEQAN_CONCEPT_LIST_suffix,~) Type;   \
    };                                                                                              \
                                                                                                    \
    template < SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_typename,~,params) >                           \
    struct name:                                                                                    \
        SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_REFINE_superclass,params,refinedConcepts)

/*!
 * @macro SEQAN_CONCEPT_IMPL
 * @brief Defines which concepts a model fulfills.
 * @headerfile seqan/basic.h
 * 
 * 
 * @signature template<> SEQAN_CONCEPT_IMPL(name, implementedConcepts)
 *            template<typename T, int I> SEQAN_CONCEPT_IMPL(name<T,I>, implementedConcepts)
 * 
 * @param implementedConcepts Identifiers of concepts that are fulfilled by the model.  This is a sequence of the
 *                            Boost Preprocessor Library, read <a
 *                            href="http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html">more</a>.
 * @param name Model type, i.e. an identifier or an identifier with template
 *             arguments.
 * 
 * @section Remarks
 * 
 * The metafunction @link Is @endlink can be used to determine whether a class
 * models (fulfills) a concepts. A model of a concept must pass the concept
 * check via @link SEQAN_CONCEPT_ASSERT @endlink.
 * 
 * @section Examples
 * 
 * @code{.cpp}
 * template <typename TValue, typename TSpec>
 * SEQAN_CONCEPT_IMPL(String<TValue, TSpec>, (StringConcept));
 * @endcode
 */

/**
.Macro.SEQAN_CONCEPT_IMPL
..cat:Concepts
..summary:Defines which concepts a model fulfills.
..signature:
template<> 
SEQAN_CONCEPT_IMPL(name, implementedConcepts)

template<typename T, int I>
SEQAN_CONCEPT_IMPL(name<T,I>, implementedConcepts)
..param.name:Model type, i.e. an identifier or an identifier with template arguments.
..param.implementedConcepts:Identifiers of concepts that are fulfilled by the model.
...remarks:This is a sequence of the Boost Preprocessor Library, read @http://www.boost.org/doc/libs/1_47_0/libs/preprocessor/doc/index.html|more@.
..remarks:The metafunction @Metafunction.Is@ can be used to determine whether a class models (fulfills) a concepts.
A model of a concept must pass the concept check via @Macro.SEQAN_CONCEPT_ASSERT@.
..example.code:
template <typename TValue, typename TSpec>
SEQAN_CONCEPT_IMPL(String<TValue, TSpec>, (StringConcept));
..include:seqan/basic.h
 */

# define SEQAN_CONCEPT_IMPL(model, implementedConcepts)                                                 \
    template <>                                                                                         \
    struct Implements<model>                                                                            \
    {                                                                                                   \
        typedef                                                                                         \
            SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_LIST_prefix,(model),implementedConcepts)              \
            SEQAN_PP_REPEAT(SEQAN_PP_SEQ_SIZE(implementedConcepts),SEQAN_CONCEPT_LIST_suffix,~) Type;   \
    }

    
// helper for the SEQAN_CONCEPT, above.
# define SEQAN_CONCEPT_typename(r, ignored, index, t) \
    SEQAN_PP_COMMA_IF(index) typename t

// helper for the SEQAN_CONCEPT, above.
# define SEQAN_CONCEPT_REFINE_superclass(r, params, index, t) \
    SEQAN_PP_COMMA_IF(index) t<SEQAN_PP_SEQ_ENUM(params)>
# define SEQAN_CONCEPT_LIST_prefix(r, params, index, t) \
    SEQAN_PP_COMMA_IF(index) TagList<t<SEQAN_PP_SEQ_ENUM(params)>
# define SEQAN_CONCEPT_LIST_suffix(z, n, text) > 

// ============================================================================
// Functions
// ============================================================================

/*!
 * @fn sameType
 * @brief Tests for equality of types.
 *
 * @signature void sameType(x, y);
 *
 * @param[in] x Object of a certain type.
 * @param[in] y Object that must be of the same type.
 *
 * This function can be used to test for the correctness of function return types or the type of an expression in
 * concept tests.
 *
 * @see SEQAN_CONCEPT_USAGE
 */

/**
.Function.sameType
..summary:Tests for equality of types.
..cat:Concepts
..signature:sameType(x, y)
..param.x: Object of a certain type.
..param.y: Object that must be of the same type.
..remarks:This function can be used to test for the correctness of function return types or the type of an expression.
..see:Macro.SEQAN_CONCEPT_USAGE
..include:seqan/basic.h
 */

template <typename T>
void sameType(T, T) { }


// ============================================================================
// Metafunctions
// ============================================================================

/*!
 * @mfn Is
 * @brief Returns whether a concept is fulfilled.
 * @headerfile seqan/basic.h
 * 
 * @signature Is<TConcept>::Type
 * @signature Is<TConcept>::VALUE
 * 
 * @tparam TConcept A concept that is specialized with type(s) that should be
 *                  tested for fulfilling the concept.
 * 
 * @return Type @link Logical Values.tag.True @endlink/<tt>true</tt> if
 *              <tt>TConcept</tt> is a fulfilled concept, otherwise @link
 *              Logical Values.tag.False @endlink/<tt>false</tt>.
 * 
 * @section Remarks
 * 
 * The @link Is @endlink-metafunction can be used to test types for fulfilling a concept without causing compilation
 * errors.  If <tt>True</tt> or <tt>true</tt> is returned, <tt>TConcept</tt> must pass the concept test via @link
 * SEQAN_CONCEPT_ASSERT @endlink.  It can be used to switch between different implementations depending on the concept
 * of a type, or in combination with @link EnableIfFunctionality#SEQAN_FUNC_ENABLE_IF @endlink to make a function only
 * visible to types of certain concepts.
 * 
 * @section Examples
 * 
 * @code{.cpp}
 * Is<SequenceConcept<TSeq> >::Type
 * IfC<Is<ContainerConcept<TSeq> >::VALUE, T1, T2>::Type
 *  
 * std::cout << Is<IntegerConcept<int> >::VALUE << std::endl;     // 1
 * std::cout << Is<IntegerConcept<double> >::VALUE << std::endl;  // 0
 * @endcode
 * Define a hierarchy of concepts and two models <tt>Alice</tt> and <tt>Bob</tt>
 * that implements some of them. @link Is @endlink determines which concepts are
 * explicitly or implicitly fulfilled.
 * 
 * @code{.cpp}
 * struct Alice {};
 * struct Bob {};
 *  
 * SEQAN_CONCEPT(ConceptA, (T)) {};
 * SEQAN_CONCEPT(ConceptB, (T)) {};
 * SEQAN_CONCEPT_REFINE(ConceptC, (T), (ConceptA)(ConceptB)) {};
 * SEQAN_CONCEPT_REFINE(ConceptD, (T), (ConceptC)) {};
 *  
 * SEQAN_CONCEPT_IMPL(Alice, (ConceptA)(ConceptB));
 * SEQAN_CONCEPT_IMPL(Bob, (ConceptC));
 *  
 * std::cout << Is< ConceptA<Alice> >::VALUE << std::endl; // 1
 * std::cout << Is< ConceptB<Alice> >::VALUE << std::endl; // 1
 * std::cout << Is< ConceptC<Alice> >::VALUE << std::endl; // 0
 * std::cout << Is< ConceptD<Alice> >::VALUE << std::endl; // 0
 *  
 * std::cout << Is< ConceptA<Bob> >::VALUE << std::endl;   // 1
 * std::cout << Is< ConceptB<Bob> >::VALUE << std::endl;   // 1
 * std::cout << Is< ConceptC<Bob> >::VALUE << std::endl;   // 1
 * std::cout << Is< ConceptD<Bob> >::VALUE << std::endl;   // 0
 * @endcode
 *
 * @see EnableIfFunctionality#SEQAN_FUNC_ENABLE_IF
 * @see SEQAN_CONCEPT_ASSERT
 */

/**
.Metafunction.Is
..cat:Concepts
..summary:Returns whether a concept is fulfilled.
..signature:Is<TConcept>::Type
..signature:Is<TConcept>::VALUE
..param.TConcept:A concept that is specialized with type(s) that should be tested for fulfilling the concept.
..returns:@Tag.Logical Values.tag.True@/$true$ if $TConcept$ is a fulfilled concept, otherwise @Tag.Logical Values.tag.False@/$false$.
..remarks:
...text:The @Metafunction.Is@-metafunction can be used to test types for fulfilling a concept without causing compilation errors.
If @Tag.Logical Values.tag.True@/$true$ is returned, $TConcept$ must pass the concept test via @Macro.SEQAN_CONCEPT_ASSERT@.
It can be used to switch between different implementations depending on the concept of a type, or in combination with @Macro.SEQAN_FUNC_ENABLE_IF@ to make a function only visible to types of certain concepts.
..example.code:
Is<SequenceConcept<TSeq> >::Type
IfC<Is<ContainerConcept<TSeq> >::VALUE, T1, T2>::Type

std::cout << Is<IntegerConcept<int> >::VALUE << std::endl;     // 1
std::cout << Is<IntegerConcept<double> >::VALUE << std::endl;  // 0
..example.text:Define a hierarchy of concepts and two models $Alice$ and $Bob$ that implements some of them.
@Metafunction.Is@ determines which concepts are explicitly or implicitly fulfilled.
..example.code:
struct Alice {};
struct Bob {};

SEQAN_CONCEPT(ConceptA, (T)) {};
SEQAN_CONCEPT(ConceptB, (T)) {};
SEQAN_CONCEPT_REFINE(ConceptC, (T), (ConceptA)(ConceptB)) {};
SEQAN_CONCEPT_REFINE(ConceptD, (T), (ConceptC)) {};

SEQAN_CONCEPT_IMPL(Alice, (ConceptA)(ConceptB));
SEQAN_CONCEPT_IMPL(Bob, (ConceptC));

std::cout << Is< ConceptA<Alice> >::VALUE << std::endl; // 1
std::cout << Is< ConceptB<Alice> >::VALUE << std::endl; // 1
std::cout << Is< ConceptC<Alice> >::VALUE << std::endl; // 0
std::cout << Is< ConceptD<Alice> >::VALUE << std::endl; // 0

std::cout << Is< ConceptA<Bob> >::VALUE << std::endl;   // 1
std::cout << Is< ConceptB<Bob> >::VALUE << std::endl;   // 1
std::cout << Is< ConceptC<Bob> >::VALUE << std::endl;   // 1
std::cout << Is< ConceptD<Bob> >::VALUE << std::endl;   // 0
..include:seqan/basic.h
..see:Macro.SEQAN_FUNC_ENABLE_IF
..see:Macro.SEQAN_CONCEPT_ASSERT
*/

// test whether a concept is fulfilled (without concept checking)
template <typename T>
struct Implements: False {};

template <typename TModel>
struct Refines
{
    typedef void Type;
};


template <typename TConceptWithModel, typename TConceptWithModelList>
struct IsRecurse_: False {};

template <typename TConceptWithModel, typename TTail>
struct IsRecurse_<TConceptWithModel, TagList<TConceptWithModel, TTail> >: True {};

template <typename TConceptModel, typename THead, typename TTail>
struct IsRecurse_< TConceptModel, TagList<THead, TTail>  >:     
    Or< 
        IsRecurse_<TConceptModel, typename Refines<THead>::Type >,
        IsRecurse_<TConceptModel, TTail>
    > {};

template <typename TConceptWithModel>
struct Is;

template <template <typename> class TConcept, typename TModel>
struct Is< TConcept<TModel> >: 
    IsRecurse_<TConcept<TModel>, typename Implements<TModel>::Type> {};


}  // namespace seqan

#endif  // #ifndef CORE_INCLUDE_SEQAN_BASIC_CONCEPT_CHECKING_H_