question about BOOST_CONCEPT_REQUIRES
#include "boost/concept/requires.hpp" #include "boost/concept_check.hpp" #include <iterator> template <typename T> BOOST_CONCEPT_REQUIRES(( ((boost::ForwardIterator<T>)) ((boost::LessThanComparable< typename std::iterator_traits<T>::value_type >)) ), (void) ) bubble_sort(T begin, T end); if I compile this with gcc 4.5.3 I get some error messages which I don't expect to see: z:\BoostRelease\libs\serialization\test\test_zmisc.cpp:13:1: error: * cannot appear in a constant-expression z:\BoostRelease\libs\serialization\test\test_zmisc.cpp:13:1: error: a call to a constructor cannot appear in a constant-expression z:\BoostRelease\libs\serialization\test\test_zmisc.cpp:13:1: error: template argument 1 is invalid z:\BoostRelease\libs\serialization\test\test_zmisc.cpp:13:1: error: template argument 1 is invalid z:\BoostRelease\libs\serialization\test\test_zmisc.cpp:14:28: error: invalid type in declaration before ; token Note this occurs even before the template declaration is invoked. Any insight would be appreciated. Robert Ramey
#include "boost/concept/requires.hpp" #include "boost/concept_check.hpp" #include <iterator> template <typename T> BOOST_CONCEPT_REQUIRES(( ((boost::ForwardIterator<T>)) ((boost::LessThanComparable< typename std::iterator_traits<T>::value_type
)) ), (void) ) bubble_sort(T begin, T end);
if I compile this with gcc 4.5.3 I get some error messages which I don't expect to see:
You have an extra pair of parentheses grouping the requirements that shouldn't be there. It should be just: BOOST_CONCEPT_REQUIRES( // note: removed one '(' ((boost::ForwardIterator<T>)) ((boost::LessThanComparable< typename std::iterator_traits<T>::value_type >)) , // note: removed ')' (void) ) bubble_sort(T begin, T end); See the example usage in the documentation [1]. Regards, Nate [1] http://www.boost.org/doc/libs/1_54_0/libs/concept_check/using_concept_check....
Nathan Ridge wrote:
#include "boost/concept/requires.hpp" #include "boost/concept_check.hpp" #include <iterator> template <typename T> BOOST_CONCEPT_REQUIRES(( ((boost::ForwardIterator<T>)) ((boost::LessThanComparable< typename std::iterator_traits<T>::value_type
)) ), (void) ) bubble_sort(T begin, T end);
if I compile this with gcc 4.5.3 I get some error messages which I don't expect to see:
You have an extra pair of parentheses grouping the requirements that shouldn't be there. It should be just:
BOOST_CONCEPT_REQUIRES( // note: removed one '(' ((boost::ForwardIterator<T>)) ((boost::LessThanComparable< typename std::iterator_traits<T>::value_type
)) , // note: removed ')' (void) ) bubble_sort(T begin, T end);
See the example usage in the documentation [1].
Regards, Nate
[1] http://www.boost.org/doc/libs/1_54_0/libs/concept_check/using_concept_check.... =
Damn! - I must of checked that 20 times! Thanks for spotting this for me. Robert Ramey
participants (2)
-
Nathan Ridge
-
Robert Ramey