Skip to content

Commit 4f3f49e

Browse files
authored
Improve compatibility with diverse build environments. (#112)
This commit bundles cherry-picked changes from the master branch to improve compatibility of the stable branch with C++11 compilers, as well as additional changes (presumably duplicating changes to the master branch) to make the Unix version compatible with Mac OS X.
1 parent 3e668f9 commit 4f3f49e

File tree

3,648 files changed

+667754
-106011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,648 files changed

+667754
-106011
lines changed

.travis.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
env:
2+
global:
3+
# Required for clang.
4+
- CXXFLAGS="-fno-fast-math"
5+
6+
branches:
7+
except:
8+
- /^v[0-9]/
9+
10+
os:
11+
- linux
12+
- osx
13+
14+
language: cpp
15+
16+
compiler:
17+
- gcc
18+
- clang
19+
20+
sudo: false
21+
22+
addons:
23+
apt:
24+
packages:
25+
- libboost-dev
26+
- libboost-date-time-dev
27+
- libboost-thread-dev
28+
- libjpeg8-dev
29+
- libopenexr-dev
30+
- libpng12-dev
31+
- libtiff4-dev
32+
- zlib1g-dev
33+
34+
install:
35+
- cd unix
36+
- ./prebuild.sh
37+
- cd ..
38+
- ./configure COMPILED_BY="Travis CI" --prefix="$(pwd)/build"
39+
- make check
40+
- make install
41+
42+
script:
43+
- true
44+
45+
notifications:
46+
email:
47+
recipients:
48+
- ${NOTIFICATION_EMAIL}
49+
on_success: change
50+
on_failure: always

appveyor.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 3.7+av{build}
2+
pull_requests:
3+
do_not_increment_build_number: true
4+
branches:
5+
except:
6+
- coverity_scan
7+
8+
image: Visual Studio 2015
9+
10+
shallow_clone: true
11+
12+
matrix:
13+
fast_finish: true
14+
15+
environment:
16+
matrix:
17+
- configuration: Release
18+
platform: x64
19+
bin_dir: bin64
20+
artifact_suffix: -Win64
21+
PlatformToolset: v140
22+
- configuration: Release-SSE2
23+
platform: Win32
24+
bin_dir: bin32
25+
artifact_suffix: -Win32-sse2
26+
PlatformToolset: v140
27+
- configuration: Release
28+
platform: Win32
29+
bin_dir: bin32
30+
artifact_suffix: -Win32
31+
PlatformToolset: v140
32+
33+
before_build:
34+
- ps: |
35+
$env:devenv = $env:VS140COMNTOOLS + '\..\IDE\devenv'
36+
& $env:devenv windows\vs10\povray.sln /upgrade
37+
(Get-Content source\backend\povray.h).replace('FILL IN NAME HERE.........................', $env:pov_authorized_by) | Set-Content source\backend\povray.h
38+
(Get-Content source\backend\povray.h).replace('#error Please complete the following DISTRIBUTION_MESSAGE_2 definition', '') | Set-Content source\backend\povray.h
39+
40+
build:
41+
project: windows/vs10/povray.sln
42+
parallel: true
43+
verbosity: minimal
44+
45+
test: off
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
Copyright (c) Marshall Clow 2014.
3+
4+
Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
Revision history:
8+
2 Dec 2014 mtc First version; power
9+
10+
*/
11+
12+
/// \file algorithm.hpp
13+
/// \brief Misc Algorithms
14+
/// \author Marshall Clow
15+
///
16+
17+
#ifndef BOOST_ALGORITHM_HPP
18+
#define BOOST_ALGORITHM_HPP
19+
20+
#include <boost/utility/enable_if.hpp> // for boost::disable_if
21+
#include <boost/type_traits/is_integral.hpp>
22+
23+
namespace boost { namespace algorithm {
24+
25+
template <typename T>
26+
T identity_operation ( std::multiplies<T> ) { return T(1); }
27+
28+
template <typename T>
29+
T identity_operation ( std::plus<T> ) { return T(0); }
30+
31+
32+
/// \fn power ( T x, Integer n )
33+
/// \return the value "x" raised to the power "n"
34+
///
35+
/// \param x The value to be exponentiated
36+
/// \param n The exponent (must be >= 0)
37+
///
38+
// \remark Taken from Knuth, The Art of Computer Programming, Volume 2:
39+
// Seminumerical Algorithms, Section 4.6.3
40+
template <typename T, typename Integer>
41+
typename boost::enable_if<boost::is_integral<Integer>, T>::type
42+
power (T x, Integer n) {
43+
T y = 1; // Should be "T y{1};"
44+
if (n == 0) return y;
45+
while (true) {
46+
if (n % 2 == 1) {
47+
y = x * y;
48+
if (n == 1)
49+
return y;
50+
}
51+
n = n / 2;
52+
x = x * x;
53+
}
54+
return y;
55+
}
56+
57+
/// \fn power ( T x, Integer n, Operation op )
58+
/// \return the value "x" raised to the power "n"
59+
/// using the operaton "op".
60+
///
61+
/// \param x The value to be exponentiated
62+
/// \param n The exponent (must be >= 0)
63+
/// \param op The operation used
64+
///
65+
// \remark Taken from Knuth, The Art of Computer Programming, Volume 2:
66+
// Seminumerical Algorithms, Section 4.6.3
67+
template <typename T, typename Integer, typename Operation>
68+
typename boost::enable_if<boost::is_integral<Integer>, T>::type
69+
power (T x, Integer n, Operation op) {
70+
T y = identity_operation(op);
71+
if (n == 0) return y;
72+
while (true) {
73+
if (n % 2 == 1) {
74+
y = op(x, y);
75+
if (n == 1)
76+
return y;
77+
}
78+
n = n / 2;
79+
x = op(x, x);
80+
}
81+
return y;
82+
}
83+
84+
}}
85+
86+
#endif // BOOST_ALGORITHM_HPP
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
Copyright (c) Marshall Clow 2008-2012.
3+
4+
Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
Revision history:
8+
27 June 2009 mtc First version
9+
23 Oct 2010 mtc Added predicate version
10+
11+
*/
12+
13+
/// \file clamp.hpp
14+
/// \brief Clamp algorithm
15+
/// \author Marshall Clow
16+
///
17+
/// Suggested by olafvdspek in https://svn.boost.org/trac/boost/ticket/3215
18+
19+
#ifndef BOOST_ALGORITHM_CLAMP_HPP
20+
#define BOOST_ALGORITHM_CLAMP_HPP
21+
22+
#include <functional> // For std::less
23+
#include <iterator> // For std::iterator_traits
24+
#include <cassert>
25+
26+
#include <boost/range/begin.hpp>
27+
#include <boost/range/end.hpp>
28+
#include <boost/mpl/identity.hpp> // for identity
29+
#include <boost/utility/enable_if.hpp> // for boost::disable_if
30+
31+
namespace boost { namespace algorithm {
32+
33+
/// \fn clamp ( T const& val,
34+
/// typename boost::mpl::identity<T>::type const & lo,
35+
/// typename boost::mpl::identity<T>::type const & hi, Pred p )
36+
/// \return the value "val" brought into the range [ lo, hi ]
37+
/// using the comparison predicate p.
38+
/// If p ( val, lo ) return lo.
39+
/// If p ( hi, val ) return hi.
40+
/// Otherwise, return the original value.
41+
///
42+
/// \param val The value to be clamped
43+
/// \param lo The lower bound of the range to be clamped to
44+
/// \param hi The upper bound of the range to be clamped to
45+
/// \param p A predicate to use to compare the values.
46+
/// p ( a, b ) returns a boolean.
47+
///
48+
template<typename T, typename Pred>
49+
T const & clamp ( T const& val,
50+
typename boost::mpl::identity<T>::type const & lo,
51+
typename boost::mpl::identity<T>::type const & hi, Pred p )
52+
{
53+
// assert ( !p ( hi, lo )); // Can't assert p ( lo, hi ) b/c they might be equal
54+
return p ( val, lo ) ? lo : p ( hi, val ) ? hi : val;
55+
}
56+
57+
58+
/// \fn clamp ( T const& val,
59+
/// typename boost::mpl::identity<T>::type const & lo,
60+
/// typename boost::mpl::identity<T>::type const & hi )
61+
/// \return the value "val" brought into the range [ lo, hi ].
62+
/// If the value is less than lo, return lo.
63+
/// If the value is greater than "hi", return hi.
64+
/// Otherwise, return the original value.
65+
///
66+
/// \param val The value to be clamped
67+
/// \param lo The lower bound of the range to be clamped to
68+
/// \param hi The upper bound of the range to be clamped to
69+
///
70+
template<typename T>
71+
T const& clamp ( const T& val,
72+
typename boost::mpl::identity<T>::type const & lo,
73+
typename boost::mpl::identity<T>::type const & hi )
74+
{
75+
return (clamp) ( val, lo, hi, std::less<T>());
76+
}
77+
78+
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
79+
/// std::iterator_traits<InputIterator>::value_type const & lo,
80+
/// std::iterator_traits<InputIterator>::value_type const & hi )
81+
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
82+
///
83+
/// \param first The start of the range of values
84+
/// \param last One past the end of the range of input values
85+
/// \param out An output iterator to write the clamped values into
86+
/// \param lo The lower bound of the range to be clamped to
87+
/// \param hi The upper bound of the range to be clamped to
88+
///
89+
template<typename InputIterator, typename OutputIterator>
90+
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
91+
typename std::iterator_traits<InputIterator>::value_type const & lo,
92+
typename std::iterator_traits<InputIterator>::value_type const & hi )
93+
{
94+
// this could also be written with bind and std::transform
95+
while ( first != last )
96+
*out++ = clamp ( *first++, lo, hi );
97+
return out;
98+
}
99+
100+
/// \fn clamp_range ( const Range &r, OutputIterator out,
101+
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
102+
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi )
103+
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
104+
///
105+
/// \param r The range of values to be clamped
106+
/// \param out An output iterator to write the clamped values into
107+
/// \param lo The lower bound of the range to be clamped to
108+
/// \param hi The upper bound of the range to be clamped to
109+
///
110+
template<typename Range, typename OutputIterator>
111+
typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
112+
clamp_range ( const Range &r, OutputIterator out,
113+
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
114+
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi )
115+
{
116+
return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi );
117+
}
118+
119+
120+
/// \fn clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
121+
/// std::iterator_traits<InputIterator>::value_type const & lo,
122+
/// std::iterator_traits<InputIterator>::value_type const & hi, Pred p )
123+
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
124+
/// using the comparison predicate p.
125+
///
126+
/// \param first The start of the range of values
127+
/// \param last One past the end of the range of input values
128+
/// \param out An output iterator to write the clamped values into
129+
/// \param lo The lower bound of the range to be clamped to
130+
/// \param hi The upper bound of the range to be clamped to
131+
/// \param p A predicate to use to compare the values.
132+
/// p ( a, b ) returns a boolean.
133+
134+
///
135+
template<typename InputIterator, typename OutputIterator, typename Pred>
136+
OutputIterator clamp_range ( InputIterator first, InputIterator last, OutputIterator out,
137+
typename std::iterator_traits<InputIterator>::value_type const & lo,
138+
typename std::iterator_traits<InputIterator>::value_type const & hi, Pred p )
139+
{
140+
// this could also be written with bind and std::transform
141+
while ( first != last )
142+
*out++ = clamp ( *first++, lo, hi, p );
143+
return out;
144+
}
145+
146+
/// \fn clamp_range ( const Range &r, OutputIterator out,
147+
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
148+
/// typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi,
149+
/// Pred p )
150+
/// \return clamp the sequence of values [first, last) into [ lo, hi ]
151+
/// using the comparison predicate p.
152+
///
153+
/// \param r The range of values to be clamped
154+
/// \param out An output iterator to write the clamped values into
155+
/// \param lo The lower bound of the range to be clamped to
156+
/// \param hi The upper bound of the range to be clamped to
157+
/// \param p A predicate to use to compare the values.
158+
/// p ( a, b ) returns a boolean.
159+
//
160+
// Disable this template if the first two parameters are the same type;
161+
// In that case, the user will get the two iterator version.
162+
template<typename Range, typename OutputIterator, typename Pred>
163+
typename boost::disable_if_c<boost::is_same<Range, OutputIterator>::value, OutputIterator>::type
164+
clamp_range ( const Range &r, OutputIterator out,
165+
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & lo,
166+
typename std::iterator_traits<typename boost::range_iterator<const Range>::type>::value_type const & hi,
167+
Pred p )
168+
{
169+
return clamp_range ( boost::begin ( r ), boost::end ( r ), out, lo, hi, p );
170+
}
171+
172+
173+
}}
174+
175+
#endif // BOOST_ALGORITHM_CLAMP_HPP

0 commit comments

Comments
 (0)