Vaucanson  1.4.1
monoid_base.hxx
1 // monoid_base.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_CONCEPT_MONOID_BASE_HXX
18 # define VCSN_ALGEBRA_CONCEPT_MONOID_BASE_HXX
19 
20 # include <vaucanson/algebra/concept/monoid_base.hh>
21 # include <vaucanson/algebra/concept/semigroup_base.hh>
22 
23 namespace vcsn {
24 
25  namespace algebra {
26 
27  /*-----------------.
28  | MonoidBase<Self> |
29  `-----------------*/
30  template<class Self>
31  template<typename T>
32  Element<Self, T>
34  {
35  return Element<Self, T>(this->self(),
36  identity_value(SELECT(Self), SELECT(T)));
37  }
38 
39  template<class Self>
40  template<typename T>
42  {
43  return Element<Self, T>(this->self(),
44  zero_value(SELECT(Self), SELECT(T)));
45  }
46 
47  template <class Self>
49  {}
50 
51  template <class Self>
53  SemigroupBase<Self>(other)
54  {}
55 
56  template <class T>
57  template <class S>
59  identity_as<T>::of(const S& s)
60  {
61  return s.identity(SELECT(T));
62  }
63 
64  template <class T>
65  template <class S>
67  zero_as<T>::of(const S& s)
68  {
69  return s.zero(SELECT(T));
70  }
71 
72  } // algebra
73 
74  /*---------------------------------.
75  | MetaElement<MonoidBase<Self>, T> |
76  `---------------------------------*/
77 
78  template<class Self, typename T>
80  {}
81 
82  template<class Self, typename T>
84  MetaElement<algebra::SemigroupBase<Self>, T>(other)
85  {}
86 
87  namespace algebra {
88 
89  template<typename T, typename Self>
90  T
92  {
93  // By default, an element of a monoid is the identity.
94  return identity_value(SELECT(Self), SELECT(T));
95  }
96 
97  } // algebra
98 
99 } // vcsn
100 
101 #endif // ! VCSN_ALGEBRA_CONCEPT_MONOID_BASE_HXX