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
|
// ==========================================================================
// SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2018, 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: David Weese <davod.weese@fu-berlin.de>
// 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 INCLUDE_SEQAN_BASIC_CONCEPT_CHECKING_H_
#define 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.
#define SEQAN_STATIC_ASSERT_MSG( B, Msg ) static_assert(B, Msg)
//
// If the compiler issues warnings about old C style casts,
// then enable this:
//
#define SEQAN_STATIC_ASSERT_BOOL_CAST(x) (bool)(x)
#define SEQAN_STATIC_ASSERT( B ) static_assert(B, #B)
// ---------------------------------------------------------------------------
// ==> 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 *p = static_cast<Model*>(NULL);
p->~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_UNUSED
// ---------------------------------------------------------------------------
// ==> 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).
/*!
* @defgroup ConceptChecking Concept Checking
* @brief Macros for the concept checking system in SeqAn.
*
* SeqAn's concept checking system is copied from Boost. The license for the library is as follows:
*
* @code{.cpp}
* // 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).
* @endcode
*/
/*!
* @macro ConceptChecking#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.
*
* 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
*/
// 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 *p = static_cast<Model*>(NULL);
p->~Model();
}
};
/*!
* @macro ConceptChecking#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 ConceptChecking#SEQAN_CONCEPT @endlink or
* @link ConceptChecking#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 ConceptChecking#requireBooleanExpr @endlink and @link ConceptChecking#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 ConceptChecking#requireBooleanExpr
* @see ConceptChecking#SEQAN_CONCEPT
* @see ConceptChecking#SEQAN_CONCEPT_REFINE
*/
#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 *p = static_cast<Model*>(NULL);
p->~Model();
}
};
struct failed {};
template <class Model>
struct requirement<failed ************ Model::************>
{
static void failed()
{
Model *p = static_cast<Model*>(NULL);
p->~Model();
}
};
template <class Model>
struct constraint
{
static void failed()
{
Model *p = static_cast<Model*>(NULL);
p->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_UNUSED
// ---------------------------------------------------------------------------
// ==> 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
* @headerfile <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.
*/
template <class T> 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 ConceptChecking#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.
*
* 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 ConceptChecking#SEQAN_CONCEPT_ASSERT
* @endlink and valid expressions in a function @link ConceptChecking#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 ConceptChecking#SEQAN_CONCEPT_USAGE
*/
# define SEQAN_CONCEPT(name, params) \
template < SEQAN_PP_SEQ_FOR_EACH_I(SEQAN_CONCEPT_typename,~,params) > \
struct name
/*!
* @macro ConceptChecking#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 parameter 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>
*
* 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 ConceptChecking#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 ConceptChecking#SEQAN_CONCEPT_USAGE
*/
# 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 ConceptChecking#SEQAN_CONCEPT_IMPL
* @brief Defines which concepts a model fulfills.
* @headerfile <seqan/basic.h>
*
*
* @signature template<> // required, even if name has no template arguments
* 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.
*
* 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 ConceptChecking#SEQAN_CONCEPT_ASSERT @endlink.
*
* @section Examples
*
* @code{.cpp}
* template <typename TValue, typename TSpec>
* SEQAN_CONCEPT_IMPL((String<TValue, TSpec>), (StringConcept));
* @endcode
*/
// STRIP_PARENS macro by Steven Watanabe (http://lists.boost.org/boost-users/2010/08/61429.php)
#define SEQAN_APPLY(macro, args) SEQAN_APPLY_I(macro, args)
#define SEQAN_APPLY_I(macro, args) macro args
#define SEQAN_STRIP_PARENS(x) SEQAN_EVAL((SEQAN_STRIP_PARENS_I x), x)
#define SEQAN_STRIP_PARENS_I(...) 1,1
#define SEQAN_EVAL(test, x) SEQAN_EVAL_I(test, x)
#define SEQAN_EVAL_I(test, x) SEQAN_MAYBE_STRIP_PARENS(SEQAN_TEST_ARITY test, x)
#define SEQAN_TEST_ARITY(...) SEQAN_APPLY(SEQAN_TEST_ARITY_I, (__VA_ARGS__, 2, 1))
#define SEQAN_TEST_ARITY_I(a,b,c,...) c
#define SEQAN_MAYBE_STRIP_PARENS(cond, x) SEQAN_MAYBE_STRIP_PARENS_I(cond, x)
#define SEQAN_MAYBE_STRIP_PARENS_I(cond, x) SEQAN_PP_CAT(SEQAN_MAYBE_STRIP_PARENS_, cond)(x)
#define SEQAN_MAYBE_STRIP_PARENS_1(x) x
#define SEQAN_MAYBE_STRIP_PARENS_2(x) SEQAN_APPLY(SEQAN_MAYBE_STRIP_PARENS_2_I, x)
#define SEQAN_MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__
# define SEQAN_CONCEPT_IMPL(model, implementedConcepts) \
struct Implements<SEQAN_STRIP_PARENS(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_STRIP_PARENS(params)>
# define SEQAN_CONCEPT_LIST_suffix(z, n, text) >
// ============================================================================
// Functions
// ============================================================================
/*!
* @fn ConceptChecking#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 ConceptChecking#SEQAN_CONCEPT_USAGE
*/
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 LogicalValuesTags#True @endlink/<tt>true</tt> if
* <tt>TConcept</tt> is a fulfilled concept, otherwise @link
* LogicalValuesTags#False @endlink/<tt>false</tt>.
*
* 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
* ConceptChecking#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<StringConcept<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)) {};
*
* template<> // Alice has no template arguments
* SEQAN_CONCEPT_IMPL(Alice, (ConceptA)(ConceptB));
*
* template<> // Bob has no template arguments
* 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 ConceptChecking#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 INCLUDE_SEQAN_BASIC_CONCEPT_CHECKING_H_
|