Changeset 1675:fa89ffb27a6d in lemon0.x for lemon/maps.h
 Timestamp:
 09/08/05 16:34:50 (15 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@2193
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/maps.h
r1669 r1675 40 40 /// Base class of maps. 41 41 /// It provides the necessary <tt>typedef</tt>s required by the map concept. 42 template<typename K, typename T> 43 class MapBase 44 { 45 public: 42 template<typename K, typename T, typename _NeedCopy = False> 43 class MapBase { 44 public: 45 /// \e 46 typedef _NeedCopy NeedCopy; 46 47 ///\e 47 48 typedef K Key; … … 55 56 /// or if you have to provide a writable map, but 56 57 /// data written to it will sent to <tt>/dev/null</tt>... 57 template<typename K, typename T> 58 class NullMap : public MapBase<K,T> 59 { 60 public: 58 template<typename K, typename T, typename NC = False> 59 class NullMap : public MapBase<K, T, NC> { 60 public: 61 typedef MapBase<K, T, NC> Parent; 62 typedef typename Parent::Key Key; 63 typedef typename Parent::Value Value; 61 64 62 typedef True NeedCopy;63 64 65 /// Gives back a default constructed element. 65 66 T operator[](const K&) const { return T(); } … … 69 70 70 71 template <typename K, typename V> 71 NullMap<K, V > nullMap() {72 return NullMap<K, V >();72 NullMap<K, V, True> nullMap() { 73 return NullMap<K, V, True>(); 73 74 } 74 75 … … 79 80 /// In other aspects it is equivalent to the \ref NullMap. 80 81 /// \todo set could be used to set the value. 81 template<typename K, typename T >82 class ConstMap : public MapBase<K, T>83 {82 template<typename K, typename T, typename NC = False> 83 class ConstMap : public MapBase<K, T, NC> { 84 private: 84 85 T v; 85 86 public: 86 87 87 typedef True NeedCopy; 88 typedef MapBase<K, T, NC> Parent; 89 typedef typename Parent::Key Key; 90 typedef typename Parent::Value Value; 88 91 89 92 /// Default constructor … … 103 106 template<typename T1> 104 107 struct rebind { 105 typedef ConstMap<K, T1> other;108 typedef ConstMap<K, T1> other; 106 109 }; 107 110 108 111 template<typename T1> 109 ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}112 ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {} 110 113 }; 111 114 … … 114 117 ///This function just returns a \ref ConstMap class. 115 118 ///\relates ConstMap 116 template<class K,class V> 117 inline ConstMap<K,V> constMap(const V &v) 118 { 119 return ConstMap<K,V>(v); 119 template<typename K, typename V> 120 inline ConstMap<K, V, True> constMap(const V &v) { 121 return ConstMap<K, V, True>(v); 120 122 } 121 123 … … 124 126 template<typename T, T v> 125 127 struct Const { }; 128 126 129 //\todo to document later 127 template<typename K, typename V, V v> 128 class ConstMap<K, Const<V, v> > : public MapBase<K, V> 129 { 130 public: 130 template<typename K, typename V, V v, typename NC> 131 class ConstMap<K, Const<V, v>, NC > : public MapBase<K, V, NC> { 132 public: 133 typedef MapBase<K, V, False> Parent; 134 typedef typename Parent::Key Key; 135 typedef typename Parent::Value Value; 136 131 137 ConstMap() { } 132 138 V operator[](const K&) const { return v; } … … 134 140 }; 135 141 142 ///Returns a \ref ConstMap class 143 144 ///This function just returns a \ref ConstMap class. 145 ///\relates ConstMap 146 template<typename K, typename V, V v> 147 inline ConstMap<K, Const<V, v>, True> constMap() { 148 return ConstMap<K, Const<V, v>, True>(); 149 } 150 136 151 /// \c std::map wrapper 137 152 … … 141 156 /// \todo Provide allocator parameter... 142 157 template <typename K, typename T, typename Compare = std::less<K> > 143 class StdMap : public std::map<K, T,Compare> {144 typedef std::map<K, T,Compare> parent;158 class StdMap : public std::map<K, T, Compare> { 159 typedef std::map<K, T, Compare> parent; 145 160 T v; 146 161 typedef typename parent::value_type PairType; … … 172 187 173 188 template<typename T1, typename Comp1> 174 StdMap(const StdMap<Key, T1,Comp1> &m, const T &_v) {189 StdMap(const StdMap<Key, T1,Comp1> &m, const T &_v) { 175 190 //FIXME; 176 191 } … … 179 194 return insert(PairType(k,v)).first > second; 180 195 } 196 181 197 ConstReference operator[](const Key &k) const { 182 198 typename parent::iterator i = lower_bound(k); … … 198 214 template<typename T1> 199 215 struct rebind { 200 typedef StdMap<Key, T1,Compare> other;216 typedef StdMap<Key, T1,Compare> other; 201 217 }; 202 218 }; … … 211 227 /// This mapping gives back the given key as value without any 212 228 /// modification. 213 template <typename T> 214 class IdentityMap { 215 public: 216 typedef T Key; 217 typedef T Value; 218 219 const Value& operator[](const Key& t) const { 229 template <typename T, typename NC = False> 230 class IdentityMap : public MapBase<T, T, NC> { 231 public: 232 typedef MapBase<T, T, NC> Parent; 233 typedef typename Parent::Key Key; 234 typedef typename Parent::Value Value; 235 236 const T& operator[](const T& t) const { 220 237 return t; 221 238 } 222 239 }; 240 241 ///Returns an \ref IdentityMap class 242 243 ///This function just returns an \ref IdentityMap class. 244 ///\relates IdentityMap 245 template<typename T> 246 inline IdentityMap<T, True> identityMap() { 247 return IdentityMap<T, True>(); 248 } 249 223 250 224 251 ///Convert the \c Value of a map to another type. … … 227 254 ///converts the \c Value of a maps to type \c T. 228 255 ///Its \c Key is inherited from \c M. 229 template <class M, class T>230 class ConvertMap {256 template <typename M, typename T, typename NC = False> 257 class ConvertMap : public MapBase<typename M::Key, T, NC> { 231 258 typename SmartConstReference<M>::Type m; 232 259 public: 233 234 typedef True NeedCopy; 235 236 ///\e 237 typedef typename M::Key Key; 238 ///\e 239 typedef T Value; 260 typedef MapBase<typename M::Key, T, NC> Parent; 261 typedef typename Parent::Key Key; 262 typedef typename Parent::Value Value; 240 263 241 264 ///Constructor … … 250 273 /// \param k The key 251 274 /// \return The target of the edge 252 Value operator[]( Keyk) const {return m[k];}275 Value operator[](const Key& k) const {return m[k];} 253 276 }; 254 277 … … 258 281 ///\relates ConvertMap 259 282 ///\todo The order of the template parameters are changed. 260 template<class T, class M> 261 inline ConvertMap<M,T> convertMap(const M &m) 262 { 263 return ConvertMap<M,T>(m); 283 template<typename T, typename M> 284 inline ConvertMap<M, T, True> convertMap(const M &m) { 285 return ConvertMap<M, T, True>(m); 264 286 } 265 287 … … 270 292 ///The \c Key and \c Value of M2 must be convertible to those of \c M1. 271 293 272 template<class M1,class M2> 273 class AddMap 274 { 294 template<typename M1, typename M2, typename NC = False> 295 class AddMap : public MapBase<typename M1::Key, typename M1::Value, NC> { 275 296 typename SmartConstReference<M1>::Type m1; 276 297 typename SmartConstReference<M2>::Type m2; 277 298 278 299 public: 279 280 typedef True NeedCopy; 281 282 ///\e 283 typedef typename M1::Key Key; 284 ///\e 285 typedef typename M1::Value Value; 300 typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent; 301 typedef typename Parent::Key Key; 302 typedef typename Parent::Value Value; 286 303 287 304 ///Constructor … … 297 314 ///\relates AddMap 298 315 ///\todo Wrong scope in Doxygen when \c \\relates is used 299 template<class M1,class M2> 300 inline AddMap<M1,M2> addMap(const M1 &m1,const M2 &m2) 301 { 302 return AddMap<M1,M2>(m1,m2); 316 template<typename M1, typename M2> 317 inline AddMap<M1, M2, True> addMap(const M1 &m1,const M2 &m2) { 318 return AddMap<M1, M2, True>(m1,m2); 303 319 } 304 320 … … 318 334 /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v); 319 335 ///\endcode 320 template<class M> 321 class ShiftMap 322 { 336 template<typename M, typename NC = False> 337 class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> { 323 338 typename SmartConstReference<M>::Type m; 324 339 typename M::Value v; 325 340 public: 326 327 typedef True NeedCopy; 328 ///\e 329 typedef typename M::Key Key; 330 ///\e 331 typedef typename M::Value Value; 341 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; 342 typedef typename Parent::Key Key; 343 typedef typename Parent::Value Value; 332 344 333 345 ///Constructor … … 336 348 ///\param _m is the undelying map 337 349 ///\param _v is the shift value 338 ShiftMap(const M &_m, const Value &_v ) : m(_m), v(_v) {};350 ShiftMap(const M &_m, const Value &_v ) : m(_m), v(_v) {}; 339 351 Value operator[](Key k) const {return m[k]+v;} 340 352 }; … … 345 357 ///\relates ShiftMap 346 358 ///\todo A better name is required. 347 template<class M> 348 inline ShiftMap<M> shiftMap(const M &m,const typename M::Value &v) 349 { 350 return ShiftMap<M>(m,v); 359 template<typename M> 360 inline ShiftMap<M, True> shiftMap(const M &m,const typename M::Value &v) { 361 return ShiftMap<M, True>(m,v); 351 362 } 352 363 … … 358 369 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. 359 370 360 template<class M1,class M2> 361 class SubMap 362 { 371 template<typename M1, typename M2, typename NC = False> 372 class SubMap : public MapBase<typename M1::Key, typename M1::Value, NC> { 363 373 typename SmartConstReference<M1>::Type m1; 364 374 typename SmartConstReference<M2>::Type m2; 365 375 public: 366 367 typedef True NeedCopy; 368 ///\e 369 typedef typename M1::Key Key; 370 ///\e 371 typedef typename M1::Value Value; 376 typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent; 377 typedef typename Parent::Key Key; 378 typedef typename Parent::Value Value; 372 379 373 380 ///Constructor … … 381 388 /// 382 389 ///\relates SubMap 383 template<class M1,class M2> 384 inline SubMap<M1,M2> subMap(const M1 &m1,const M2 &m2) 385 { 386 return SubMap<M1,M2>(m1,m2); 390 template<typename M1, typename M2> 391 inline SubMap<M1, M2, True> subMap(const M1 &m1, const M2 &m2) { 392 return SubMap<M1, M2, True>(m1, m2); 387 393 } 388 394 … … 395 401 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. 396 402 397 template<class M1,class M2> 398 class MulMap 399 { 403 template<typename M1, typename M2, typename NC = False> 404 class MulMap : public MapBase<typename M1::Key, typename M1::Value, NC> { 400 405 typename SmartConstReference<M1>::Type m1; 401 406 typename SmartConstReference<M2>::Type m2; 402 407 public: 403 404 typedef True NeedCopy; 405 ///\e 406 typedef typename M1::Key Key; 407 ///\e 408 typedef typename M1::Value Value; 408 typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent; 409 typedef typename Parent::Key Key; 410 typedef typename Parent::Value Value; 409 411 410 412 ///Constructor … … 417 419 ///This function just returns a \ref MulMap class. 418 420 ///\relates MulMap 419 template<class M1,class M2> 420 inline MulMap<M1,M2> mulMap(const M1 &m1,const M2 &m2) 421 { 422 return MulMap<M1,M2>(m1,m2); 421 template<typename M1, typename M2> 422 inline MulMap<M1, M2, True> mulMap(const M1 &m1,const M2 &m2) { 423 return MulMap<M1, M2, True>(m1,m2); 423 424 } 424 425 … … 438 439 /// MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v); 439 440 ///\endcode 440 template<class M> 441 class ScaleMap 442 { 441 template<typename M, typename NC = False> 442 class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> { 443 443 typename SmartConstReference<M>::Type m; 444 444 typename M::Value v; 445 445 public: 446 447 typedef True NeedCopy; 448 ///\e 449 typedef typename M::Key Key; 450 ///\e 451 typedef typename M::Value Value; 446 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; 447 typedef typename Parent::Key Key; 448 typedef typename Parent::Value Value; 452 449 453 450 ///Constructor … … 465 462 ///\relates ScaleMap 466 463 ///\todo A better name is required. 467 template<class M> 468 inline ScaleMap<M> scaleMap(const M &m,const typename M::Value &v) 469 { 470 return ScaleMap<M>(m,v); 464 template<typename M> 465 inline ScaleMap<M, True> scaleMap(const M &m,const typename M::Value &v) { 466 return ScaleMap<M, True>(m,v); 471 467 } 472 468 … … 478 474 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. 479 475 480 template<class M1,class M2> 481 class DivMap 482 { 476 template<typename M1, typename M2, typename NC = False> 477 class DivMap : public MapBase<typename M1::Key, typename M1::Value, NC> { 483 478 typename SmartConstReference<M1>::Type m1; 484 479 typename SmartConstReference<M2>::Type m2; 485 480 public: 486 487 typedef True NeedCopy; 488 ///\e 489 typedef typename M1::Key Key; 490 ///\e 491 typedef typename M1::Value Value; 481 typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent; 482 typedef typename Parent::Key Key; 483 typedef typename Parent::Value Value; 492 484 493 485 ///Constructor … … 500 492 ///This function just returns a \ref DivMap class. 501 493 ///\relates DivMap 502 template<class M1,class M2> 503 inline DivMap<M1,M2> divMap(const M1 &m1,const M2 &m2) 504 { 505 return DivMap<M1,M2>(m1,m2); 494 template<typename M1, typename M2> 495 inline DivMap<M1, M2, True> divMap(const M1 &m1,const M2 &m2) { 496 return DivMap<M1, M2, True>(m1,m2); 506 497 } 507 498 … … 514 505 ///then for 515 506 ///\code 516 /// ComposeMap<M1, M2> cm(m1,m2);507 /// ComposeMap<M1, M2> cm(m1,m2); 517 508 ///\endcode 518 509 /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt> … … 523 514 ///\todo Check the requirements. 524 515 525 template<class M1,class M2> 526 class ComposeMap 527 { 516 template <typename M1, typename M2, typename NC = False> 517 class ComposeMap : public MapBase<typename M2::Key, typename M1::Value, NC> { 528 518 typename SmartConstReference<M1>::Type m1; 529 519 typename SmartConstReference<M2>::Type m2; 530 520 public: 531 532 typedef True NeedCopy; 533 ///\e 534 typedef typename M2::Key Key; 535 ///\e 536 typedef typename M1::Value Value; 521 typedef MapBase<typename M2::Key, typename M1::Value, NC> Parent; 522 typedef typename Parent::Key Key; 523 typedef typename Parent::Value Value; 537 524 538 525 ///Constructor … … 545 532 /// 546 533 ///\relates ComposeMap 547 template<class M1,class M2> 548 inline ComposeMap<M1,M2> composeMap(const M1 &m1,const M2 &m2) 549 { 550 return ComposeMap<M1,M2>(m1,m2); 534 template <typename M1, typename M2> 535 inline ComposeMap<M1, M2, True> composeMap(const M1 &m1,const M2 &m2) { 536 return ComposeMap<M1, M2, True>(m1,m2); 551 537 } 552 538 … … 564 550 ///then for 565 551 ///\code 566 /// CombineMap<M1, M2,F,V> cm(m1,m2,f);552 /// CombineMap<M1, M2,F,V> cm(m1,m2,f); 567 553 ///\endcode 568 554 /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt> … … 574 560 ///\todo Check the requirements. 575 561 576 template<class M1,class M2,class F,class V = typename F::result_type> 577 class CombineMap 578 { 562 template<typename M1, typename M2, typename F, 563 typename V = typename F::result_type, 564 typename NC = False> 565 class CombineMap : public MapBase<typename M1::Key, V, NC> { 579 566 typename SmartConstReference<M1>::Type m1; 580 567 typename SmartConstReference<M2>::Type m2; 581 568 F f; 582 569 public: 583 584 typedef True NeedCopy; 585 ///\e 586 typedef typename M1::Key Key; 587 ///\e 588 typedef V Value; 570 typedef MapBase<typename M1::Key, V, NC> Parent; 571 typedef typename Parent::Key Key; 572 typedef typename Parent::Value Value; 589 573 590 574 ///Constructor … … 610 594 /// 611 595 ///\relates CombineMap 612 template<class M1,class M2,class F> 613 inline CombineMap<M1,M2,F> combineMap(const M1 &m1,const M2 &m2,const F &f) 614 { 615 return CombineMap<M1,M2,F>(m1,m2,f); 596 template<typename M1, typename M2, typename F, typename V> 597 inline CombineMap<M1, M2, F, V, True> 598 combineMap(const M1& m1,const M2& m2, const F& f) { 599 return CombineMap<M1, M2, F, V, True>(m1,m2,f); 600 } 601 602 template<typename M1, typename M2, typename F> 603 inline CombineMap<M1, M2, F, typename F::result_type, True> 604 combineMap(const M1& m1, const M2& m2, const F& f) { 605 return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f); 606 } 607 608 template<typename M1, typename M2, typename K1, typename K2, typename V> 609 inline CombineMap<M1, M2, V (*)(K1, K2), V, True> 610 combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) { 611 return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f); 616 612 } 617 613 … … 624 620 ///The unary \c  operator must be defined for \c Value, of course. 625 621 626 template<class M> 627 class NegMap 628 { 622 template<typename M, typename NC = False> 623 class NegMap : public MapBase<typename M::Key, typename M::Value, NC> { 629 624 typename SmartConstReference<M>::Type m; 630 625 public: 631 632 typedef True NeedCopy; 633 ///\e 634 typedef typename M::Key Key; 635 ///\e 636 typedef typename M::Value Value; 626 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; 627 typedef typename Parent::Key Key; 628 typedef typename Parent::Value Value; 637 629 638 630 ///Constructor … … 645 637 ///This function just returns a \ref NegMap class. 646 638 ///\relates NegMap 647 template<class M> 648 inline NegMap<M> negMap(const M &m) 649 { 650 return NegMap<M>(m); 639 template <typename M> 640 inline NegMap<M, True> negMap(const M &m) { 641 return NegMap<M, True>(m); 651 642 } 652 643 … … 675 666 676 667 677 template<class M> 678 class AbsMap 679 { 668 template<typename M, typename NC = False> 669 class AbsMap : public MapBase<typename M::Key, typename M::Value, NC> { 680 670 typename SmartConstReference<M>::Type m; 681 671 public: 682 683 typedef True NeedCopy; 684 ///\e 685 typedef typename M::Key Key; 686 ///\e 687 typedef typename M::Value Value; 672 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; 673 typedef typename Parent::Key Key; 674 typedef typename Parent::Value Value; 688 675 689 676 ///Constructor 690 677 AbsMap(const M &_m) : m(_m) {}; 691 Value operator[](Key k) const {Value tmp=m[k]; return tmp>=0?tmp:tmp;} 678 Value operator[](Key k) const { 679 Value tmp = m[k]; 680 return tmp >= 0 ? tmp : tmp; 681 } 682 692 683 }; 693 684 … … 696 687 ///This function just returns a \ref AbsMap class. 697 688 ///\relates AbsMap 698 template<class M> 699 inline AbsMap<M> absMap(const M &m) 700 { 701 return AbsMap<M>(m); 689 template<typename M> 690 inline AbsMap<M, True> absMap(const M &m) { 691 return AbsMap<M, True>(m); 702 692 } 703 693 … … 715 705 716 706 717 template<class K,class V,class F> 718 class FunctorMap 719 { 707 template<typename F, 708 typename K = typename F::argument_type, 709 typename V = typename F::result_type, 710 typename NC = False> 711 class FunctorMap : public MapBase<K, V, NC> { 720 712 const F &f; 721 713 public: 722 723 typedef True NeedCopy; 724 ///\e 725 typedef K Key; 726 ///\e 727 typedef V Value; 714 typedef MapBase<K, V, NC> Parent; 715 typedef typename Parent::Key Key; 716 typedef typename Parent::Value Value; 728 717 729 718 ///Constructor … … 738 727 ///The third template parameter isn't necessary to be given. 739 728 ///\relates FunctorMap 740 template<class K,class V, class F> 741 inline FunctorMap<K,V,F> functorMap(const F &f) 742 { 743 return FunctorMap<K,V,F>(f); 744 } 729 template<typename K, typename V, typename F> inline 730 FunctorMap<F, K, V, True> functorMap(const F &f) { 731 return FunctorMap<F, K, V, True>(f); 732 } 733 734 template <typename F> inline 735 FunctorMap<F, typename F::argument_type, typename F::result_type, True> 736 functorMap(const F &f) { 737 return functorMap<typename F::argument_type, 738 typename F::result_type, F>(f); 739 } 740 741 template <typename K, typename V> inline 742 FunctorMap<V (*)(K), K, V, True> functorMap(V (*f)(K)) { 743 return functorMap<K, V, V (*)(K)>(f); 744 } 745 745 746 746 747 ///Converts a map to an STL style (unary) functor … … 753 754 ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist. 754 755 755 template<class M> 756 class MapFunctor 757 { 756 template <typename M, typename NC = False> 757 class MapFunctor : public MapBase<typename M::Key, typename M::Value, NC> { 758 758 typename SmartConstReference<M>::Type m; 759 759 public: 760 761 typedef True NeedCopy; 760 typedef MapBase<typename M::Key, typename M::Value, NC> Parent; 761 typedef typename Parent::Key Key; 762 typedef typename Parent::Value Value; 763 762 764 ///\e 763 765 typedef typename M::Key argument_type; 764 766 ///\e 765 767 typedef typename M::Value result_type; 766 ///\e767 typedef typename M::Key Key;768 ///\e769 typedef typename M::Value Value;770 768 771 769 ///Constructor … … 781 779 ///This function just returns a \ref MapFunctor class. 782 780 ///\relates MapFunctor 783 template<class M> 784 inline MapFunctor<M> mapFunctor(const M &m) 785 { 786 return MapFunctor<M>(m); 781 template<typename M> 782 inline MapFunctor<M, True> mapFunctor(const M &m) { 783 return MapFunctor<M, True>(m); 787 784 } 788 785 … … 799 796 ///The \c Key and \c Value of M2 must be convertible from those of \c M1. 800 797 801 template<class M1,class M2> 802 class ForkMap 803 { 798 template<typename M1, typename M2, typename NC = False> 799 class ForkMap : public MapBase<typename M1::Key, typename M1::Value, NC> { 804 800 typename SmartConstReference<M1>::Type m1; 805 801 typename SmartConstReference<M2>::Type m2; 806 802 public: 807 808 typedef True NeedCopy; 809 ///\e 810 typedef typename M1::Key Key; 811 ///\e 812 typedef typename M1::Value Value; 803 typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent; 804 typedef typename Parent::Key Key; 805 typedef typename Parent::Value Value; 813 806 814 807 ///Constructor 815 808 ForkMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {}; 816 809 Value operator[](Key k) const {return m1[k];} 817 void set(Key k,const Value &v) {m1.set(k,v); m2.set(k,v);}810 // void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);} 818 811 }; 819 812 … … 825 818 ///\relates ForkMap 826 819 ///\todo Wrong scope in Doxygen when \c \\relates is used 827 template<class M1,class M2> 828 inline ForkMap<M1,M2> forkMap(const M1 &m1,const M2 &m2) 829 { 830 return ForkMap<M1,M2>(m1,m2); 820 template <typename M1, typename M2> 821 inline ForkMap<M1, M2, True> forkMap(const M1 &m1,const M2 &m2) { 822 return ForkMap<M1, M2, True>(m1,m2); 831 823 } 832 824 … … 843 835 ///its Value is <tt>bool</tt>. 844 836 845 template<class M> 846 class NotMap 847 { 837 template <typename M, typename NC = False> 838 class NotMap : public MapBase<typename M::Key, bool, NC> { 848 839 typename SmartConstReference<M>::Type m; 849 840 public: 850 851 typedef True NeedCopy; 852 ///\e 853 typedef typename M::Key Key; 854 ///\e 855 typedef bool Value; 841 typedef MapBase<typename M::Key, bool, NC> Parent; 842 typedef typename Parent::Key Key; 843 typedef typename Parent::Value Value; 856 844 857 845 ///Constructor … … 864 852 ///This function just returns a \ref NotMap class. 865 853 ///\relates NotMap 866 template<class M> 867 inline NotMap<M> notMap(const M &m) 868 { 869 return NotMap<M>(m); 870 } 871 872 873 874 875 876 854 template <typename M> 855 inline NotMap<M, True> notMap(const M &m) { 856 return NotMap<M, True>(m); 857 } 877 858 878 859
Note: See TracChangeset
for help on using the changeset viewer.