Commit 5d2a29c5 authored by Edwin Carlinet's avatar Edwin Carlinet Committed by Michaël Roynard

Set C++17 as new standard

parent 7b60c8c2
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.8.2)
project(MILENA)
# Add FindTBB directory to CMake's module path
......@@ -26,9 +26,9 @@ if(MSVC OR APPLE)
endif()
add_library(Mln INTERFACE)
# target_compile_features(Mln INTERFACE cxx_std_14)
target_include_directories(Mln INTERFACE ${MLN_INCLUDE_DIR})
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
include_directories(${FreeImage_INCLUDE_DIRS})
link_directories(${FreeImage_LIBRARY_DIR})
......@@ -47,16 +47,28 @@ if (UNIX AND NOT APPLE)
link_libraries(rt)
endif()
# Compiler configurations
target_compile_features(Mln INTERFACE cxx_std_17)
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall -std=c++14 -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX /W4 /wd4244 /wd4127 /permissive- /std:c++14" )
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_compile_options("-Wextra" "-Wall" "-Werror")
endif()
#### MSVC Compiler Configuration
if (MSVC)
add_compile_options("/wd4458" # masque le membre de classe
"/wd4456" # masque la déclaration locale précédente
"/wd5030" # l'attribut 'noinline' n'est pas reconnu
"/wd4457" # la déclaration de '?' masque le paramètre de fonction
)
add_compile_options("/WX" "/W4" "/wd4244" "/wd4127" "/permissive-")
add_compile_definitions(_SCL_SECURE_NO_WARNINGS)
add_compile_definitions(_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
add_compile_definitions(_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
endif(MSVC)
# default buidling type
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
......
......@@ -13,15 +13,16 @@ Milena with the following objectives:
Pylene is developed in modern C++. You need a modern C++ compatible compiler:
* GCC 7
* Clang 5
* Clang 6
* Microsoft Visual Studio 2017
External dependancies:
[FreeImage](www.freeimage.sourceforge.net) (only for IO)
# Status
* GCC 7.2
* Clang 5.0
* GCC 8.2.0
* Clang 6.0.1
* MSVC 15.8.1
[![pipeline status](https://gitlab.lrde.epita.fr/olena/pylene/badges/dev/pipeline.svg)](https://gitlab.lrde.epita.fr/olena/pylene/commits/dev)
......@@ -34,4 +35,4 @@ Link to the [C++ Documentation](http://olena.pages.lrde.epita.fr/pylene/)
## Presentations
Other resources (mind the dates, the library probably has changed since then):
* [A Modern C++ Library for Generic and Efficient Image Processing (GTGDMM'18)](https://www.lrde.epita.fr/dload/presentations/2018-06-19-geraud.2018.gtgdmmm.pdf)
\ No newline at end of file
* [A Modern C++ Library for Generic and Efficient Image Processing (GTGDMM'18)](https://www.lrde.epita.fr/dload/presentations/2018-06-19-geraud.2018.gtgdmmm.pdf)
......@@ -45,6 +45,10 @@ namespace mln
using base::base;
// Required because of a MS bug
// (https://developercommunity.visualstudio.com/content/problem/47799/vc-default-constructor-deleted.html)
image2d() = default;
image2d(short nrows, short ncols, unsigned border = 3, const T& init = T())
: base(box<short, 2>{{0, 0}, {nrows, ncols}}, border, init)
{
......
......@@ -11,29 +11,32 @@ namespace mln
template <typename, unsigned, typename>
struct ndimage_base;
template <typename T, unsigned dim, typename E, typename Domain>
typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
const E>::type
make_subimage(const ndimage_base<T, dim, E>&, const Domain& domain);
std::enable_if_t<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
const E>
make_subimage(const ndimage_base<T, dim, E>&, const Domain& domain);
template <typename T, unsigned dim, typename E, typename Domain>
typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value, E>::type
make_subimage(ndimage_base<T, dim, E>&, const Domain& domain);
template <typename T_, unsigned dim_, typename E_, typename Domain_>
std::enable_if_t<std::is_convertible<Domain_, typename ndimage_base<T_, dim_, E_>::domain_type>::value, E_>
make_subimage(ndimage_base<T_, dim_, E_>&, const Domain_& domain);
template <typename T, unsigned dim, typename E, typename Domain>
typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value, E>::type
make_subimage(ndimage_base<T, dim, E>&&, const Domain& domain);
std::enable_if_t<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value, E>
make_subimage(ndimage_base<T, dim, E>&&, const Domain& domain);
/******************************************/
/**** Implementation ****/
/******************************************/
template <typename T, unsigned dim, typename E, typename Domain>
inline typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
E>::type
make_subimage(ndimage_base<T, dim, E>& image, const Domain& domain)
template <typename T_, unsigned dim_, typename E_, typename Domain_>
std::enable_if_t<std::is_convertible<Domain_, typename ndimage_base<T_, dim_, E_>::domain_type>::value, E_>
make_subimage(ndimage_base<T_, dim_, E_>& image, const Domain_& domain)
{
E other(exact(image));
E_ other(exact(image));
other.m_domain = domain;
other.m_border = image.m_border; // FIXME
other.m_ptr = (char*)&image(domain.pmin);
......@@ -44,17 +47,19 @@ namespace mln
return other;
}
template <typename T, unsigned dim, typename E, typename Domain>
inline typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
const E>::type
std::enable_if_t<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
const E>
make_subimage(const ndimage_base<T, dim, E>& image, const Domain& domain)
{
return make_subimage(const_cast<ndimage_base<T, dim, E>&>(image), domain);
}
template <typename T, unsigned dim, typename E, typename Domain>
inline typename std::enable_if<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
E>::type
std::enable_if_t<std::is_convertible<Domain, typename ndimage_base<T, dim, E>::domain_type>::value,
E>
make_subimage(ndimage_base<T, dim, E>&& image, const Domain& domain)
{
return make_subimage(image, domain);
......
......@@ -20,7 +20,7 @@ namespace mln {
const std::array<point3d, 6> c6_t::dpoints = {
{{-1, 0, 0}, {0, -1, 0}, {0, 0, -1}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}};
struct c26_t : dyn_neighborhood_base<constant_neighborhood_tag, c8_t>
struct c26_t : dyn_neighborhood_base<constant_neighborhood_tag, c26_t>
{
static const int static_size = 26;
static const std::array<point3d, 26> dpoints;
......
......@@ -94,7 +94,7 @@ namespace mln
{
}
sliding_pixter_base(sliding_pixter_base& other)
sliding_pixter_base(sliding_pixter_base&& other)
: m_set(std::move(other.m_set)), m_pixel(std::move(other.m_pixel)), m_pset_iter(rng::iter(m_set))
{
}
......
......@@ -96,79 +96,79 @@ namespace mln
#endif
template <typename U, typename V = U>
struct add : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct add
{
typename std::common_type<U, V>::type operator()(const U& x, const V& y) const { return x + y; }
};
template <typename U, typename V = U>
struct substract : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct substract
{
typename std::common_type<U, V>::type operator()(const U& x, const V& y) const { return x - y; }
};
template <typename U, typename V = U>
struct multiplies : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct multiplies
{
typename std::common_type<U, V>::type operator()(const U& x, const V& y) const { return x * y; }
};
template <typename U, typename V = U>
struct devides : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct devides
{
typename std::common_type<U, V>::type operator()(const U& x, const V& y) const { return x / y; }
};
template <typename U, typename V = U>
struct modulo : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct modulo
{
typename std::common_type<U, V>::type operator()(const U& x, const V& y) const { return x % y; }
};
template <typename U, typename V = U>
struct equal_to : std::binary_function<U, V, bool>
struct equal_to
{
bool operator()(const U& x, const V& y) const { return x == y; }
};
template <typename U, typename V = U>
struct not_equal_to : std::binary_function<U, V, bool>
struct not_equal_to
{
bool operator()(const U& x, const V& y) const { return x != y; }
};
template <typename U, typename V = U>
struct less_than : std::binary_function<U, V, bool>
struct less_than
{
bool operator()(const U& x, const V& y) const { return x < y; }
};
template <typename U, typename V = U>
struct greater_than : std::binary_function<U, V, bool>
struct greater_than
{
bool operator()(const U& x, const V& y) const { return x > y; }
};
template <typename U, typename V = U>
struct less_equal : std::binary_function<U, V, bool>
struct less_equal
{
bool operator()(const U& x, const V& y) const { return x <= y; }
};
template <typename U, typename V = U>
struct greater_equal : std::binary_function<U, V, bool>
struct greater_equal
{
bool operator()(const U& x, const V& y) const { return x >= y; }
};
template <typename U, typename V = U>
struct logical_and : std::binary_function<U, V, bool>
struct logical_and
{
bool operator()(const U& x, const V& y) const { return x && y; }
};
template <typename U, typename V = U>
struct logical_or : std::binary_function<U, V, bool>
struct logical_or
{
bool operator()(const U& x, const V& y) const { return x || y; }
};
......@@ -263,7 +263,7 @@ namespace mln
{
template <class U, class V = U>
struct max_t : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct max_t
{
typedef typename std::common_type<U, V>::type R;
......@@ -271,7 +271,7 @@ namespace mln
};
template <class U, class V = U>
struct min_t : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct min_t
{
typedef typename std::common_type<U, V>::type R;
......@@ -279,7 +279,7 @@ namespace mln
};
template <class U, class V = U>
struct inf_t : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct inf_t
{
typedef typename std::common_type<U, V>::type R;
......@@ -287,7 +287,7 @@ namespace mln
};
template <class U, class V = U>
struct sup_t : std::binary_function<U, V, typename std::common_type<U, V>::type>
struct sup_t
{
typedef typename std::common_type<U, V>::type R;
......
......@@ -105,10 +105,10 @@ namespace mln
// they are close enough to use them. So:
// k0(r) = a0 * t + b0
// k2(r) = a2 * t + b2
const float a0 = 0.22498089194617754;
const float b0 = -0.74997778133276127;
const float a2 = 0.092868889904065763;
const float b2 = 0.03471904979442568;
const float a0 = 0.22498089194617754f;
const float b0 = -0.74997778133276127f;
const float a2 = 0.092868889904065763f;
const float b2 = 0.03471904979442568f;
k0 = (radius < 11) ? (1 + (radius+1) % 2) : static_cast<int>(std::round(a0 * radius + b0));
k2 = (radius < 7) ? 0 : static_cast<int>(std::round(a2 * radius + b2));
......
......@@ -40,8 +40,8 @@ namespace mln
~scoped_trace();
private:
template <class T = void> void entering(const char* desc) __mln__attribute__((noinline));
template <class T = void> void exiting() __mln__attribute__((noinline));
template <class T = void> [[gnu::noinline]] void entering(const char* desc);
template <class T = void> [[gnu::noinline]] void exiting();
int m_depth;
std::string m_desc;
......@@ -95,9 +95,8 @@ namespace mln
namespace impl
{
template <class T = void> void warn(const char* msg) __attribute__((noinline));
template <class T>
template <class T = void>
[[gnu::noinline]]
void warn(const char* msg)
{
for (int k = 0; k < __stack_depth; ++k)
......
......@@ -62,7 +62,7 @@ namespace mln
inline std::array<P, N> arr_x2(const std::array<P, N>& arr)
{
std::array<P, N> out;
for (unsigned i = 0; i < N; ++i)
for (std::size_t i = 0; i < N; ++i)
out[i] = arr[i] * 2;
return out;
}
......
......@@ -254,7 +254,7 @@ namespace mln
adjacency_edge_iterator(const inner_iterator& inner, const sbox2d& domain, const point2d& psrc,
const point2d& psink, const point2d& v)
: m_src(psrc), m_sink(psink), m_inner_it(inner), m_domain_it(domain.iter()), m_point(&v)
: m_src(psrc), m_sink(psink), m_inner_it(inner), m_domain_it(domain.iter()), m_point(&v), m_edge()
{
}
......
......@@ -113,7 +113,7 @@ namespace mln
std::pair<mln_ch_value(I, Label), Label> blobs(const Image<I>& ima_, Neighborhood nbh, Label lbl)
{
typedef mln_value(I) V;
static_assert(std::is_same<V, bool>::value, "Only supports binary image (type: bool)");
static_assert(std::is_convertible<V, bool>::value, "Only supports binary image (type: bool)");
mln_entering("mln::labeling::blobs");
......
......@@ -94,7 +94,7 @@ namespace mln
const auto n_root = zfindroot(parent, nxPar->val());
if (n_root != root)
{
is_possible_minimum &= output(n_root);
is_possible_minimum = is_possible_minimum && output(n_root);
auto roots = std::minmax(root, n_root);
parent(roots.second) = roots.first;
root = roots.first;
......
......@@ -151,7 +151,7 @@ namespace mln
}
// This is the version for regular 2D domain with periodic_line
template <class I, class Compare, class J, class OpTraits>
template <class I, class J, class OpTraits>
void dilation_dispatch_2(const I& input, const se::periodic_line2d& line, J& output, OpTraits __op__, box2d __domain__)
{
(void) __domain__;
......
......@@ -22,12 +22,13 @@ namespace mln
template <class I, typename Compare>
struct pqueue_cmp_t
{
using size_type = typename I::size_type;
const I& m_ima;
Compare m_cmp;
pqueue_cmp_t(const I& ima, const Compare& cmp) : m_ima(ima), m_cmp(cmp) {}
bool operator()(std::size_t p, std::size_t q) { return m_cmp(m_ima[p], m_ima[q]); }
bool operator()(size_type p, size_type q) { return m_cmp(m_ima[p], m_ima[q]); }
};
}
......
......@@ -26,20 +26,11 @@ include_directories(${GTEST_INCLUDE_DIRS})
# Executable: The name of the executable (default: ${Prefix}${TestName})
# Sources: The source files to compile (default: ${Prefix}${TestName}.cpp)
macro(add_core_test Executable)
set(Sources ${ARGN})
add_executable(${Executable} ${Sources})
add_test(NAME ${Executable} COMMAND ${Executable} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
target_link_libraries(${Executable} Mln)
if (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES})
else (WIN32)
target_link_libraries(${Executable} ${GTEST_BOTH_LIBRARIES} pthread)
endif (WIN32)
add_dependencies(check ${Executable})
set(Sources ${ARGN})
add_executable(${Executable} ${Sources})
add_test(NAME ${Executable} COMMAND ${Executable} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
target_link_libraries(${Executable} Mln GTest::GTest GTest::Main)
add_dependencies(check ${Executable})
endmacro(add_core_test)
add_subdirectory(accu)
......
......@@ -86,25 +86,25 @@ struct iterator_test_empty_domain : iterator_test
TEST(Core, Image2d_empty_domain_iterator_test_forward_viter)
{
iterator_test_empty_domain it{};
iterator_test_empty_domain it;
it.test_forward_viter();
}
TEST(Core, Image2d_empty_domain_iterator_test_backward_viter)
{
iterator_test_empty_domain it{};
iterator_test_empty_domain it;
it.test_backward_viter();
}
TEST(Core, Image2d_empty_domain_iterator_test_forward_pixter)
{
iterator_test_empty_domain it{};
iterator_test_empty_domain it;
it.test_forward_pixter();
}
TEST(Core, Image2d_empty_domain_iterator_test_backward_pixter)
{
iterator_test_empty_domain it{};
iterator_test_empty_domain it;
it.test_backward_pixter();
}
......
......@@ -23,7 +23,7 @@ struct rgb
bool operator==(const rgb& other) const { return r == other.r and g == other.g and b == other.b; }
};
struct red : std::unary_function<rgb&, int&>
struct red
{
int& operator()(rgb& x) const { return x.r; }
......
......@@ -66,8 +66,7 @@ TEST(Core, SubImage_sub_domain_with_box)
fill(ima | box2d{{1, 1}, {4, 4}} | box2d{{1, 1}, {2, 3}}, 42);
MLN_CHECK_IMEQUAL(ima, ref);
}
static_assert(std::is_same<decltype(ima | box2d()), image2d<int>>::value, "");
static_assert(std::is_same<decltype(ima | box2d()), image2d<int>>::value);
}
TEST(Core, SubImage_sub_domain)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment