Vaucanson
1.4.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
vaucanson
algebra
concept
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>
33
MonoidBase<Self>::identity
(
SELECTOR
(T))
const
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>
41
Element<Self, T>
MonoidBase<Self>::zero
(
SELECTOR
(T))
const
42
{
43
return
Element<Self, T>
(this->
self
(),
44
zero_value(
SELECT
(Self),
SELECT
(T)));
45
}
46
47
template
<
class
Self>
48
MonoidBase<Self>::MonoidBase
()
49
{}
50
51
template
<
class
Self>
52
MonoidBase<Self>::MonoidBase
(
const
MonoidBase
& other) :
53
SemigroupBase
<Self>(other)
54
{}
55
56
template
<
class
T>
57
template
<
class
S>
58
Element<S, T>
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>
66
Element<S, T>
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>
79
MetaElement<algebra::MonoidBase<Self>
, T>
::MetaElement
()
80
{}
81
82
template
<
class
Self,
typename
T>
83
MetaElement<algebra::MonoidBase<Self>
, T>
::MetaElement
(
const
MetaElement
& other) :
84
MetaElement
<algebra::SemigroupBase<Self>, T>(other)
85
{}
86
87
namespace
algebra {
88
89
template
<
typename
T,
typename
Self>
90
T
91
op_default(
SELECTOR
(
algebra::MonoidBase<Self>
),
SELECTOR
(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
Generated on Sat Jul 14 2012 18:46:40 for Vaucanson by
1.8.1.1